mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-12 08:13:26 +01:00
[AltStore] Revises authentication flow with better UI
This commit is contained in:
59
AltStore/Model/Account.swift
Normal file
59
AltStore/Model/Account.swift
Normal file
@@ -0,0 +1,59 @@
|
||||
//
|
||||
// Account.swift
|
||||
// AltStore
|
||||
//
|
||||
// Created by Riley Testut on 6/5/19.
|
||||
// Copyright © 2019 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
import AltSign
|
||||
|
||||
@objc(Account)
|
||||
class Account: NSManagedObject
|
||||
{
|
||||
var localizedName: String {
|
||||
var components = PersonNameComponents()
|
||||
components.givenName = self.firstName
|
||||
components.familyName = self.lastName
|
||||
|
||||
let name = PersonNameComponentsFormatter.localizedString(from: components, style: .default)
|
||||
return name
|
||||
}
|
||||
|
||||
/* Properties */
|
||||
@NSManaged var appleID: String
|
||||
@NSManaged var identifier: String
|
||||
|
||||
@NSManaged var firstName: String
|
||||
@NSManaged var lastName: String
|
||||
|
||||
/* Relationships */
|
||||
@NSManaged var teams: Set<Team>
|
||||
|
||||
private override init(entity: NSEntityDescription, insertInto context: NSManagedObjectContext?)
|
||||
{
|
||||
super.init(entity: entity, insertInto: context)
|
||||
}
|
||||
|
||||
init(_ account: ALTAccount, context: NSManagedObjectContext)
|
||||
{
|
||||
super.init(entity: Account.entity(), insertInto: context)
|
||||
|
||||
self.appleID = account.appleID
|
||||
self.identifier = account.identifier
|
||||
|
||||
self.firstName = account.firstName
|
||||
self.lastName = account.lastName
|
||||
}
|
||||
}
|
||||
|
||||
extension Account
|
||||
{
|
||||
@nonobjc class func fetchRequest() -> NSFetchRequest<Account>
|
||||
{
|
||||
return NSFetchRequest<Account>(entityName: "Account")
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="14490.99" systemVersion="18F203" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
|
||||
<entity name="Account" representedClassName="Account" syncable="YES">
|
||||
<attribute name="appleID" attributeType="String" syncable="YES"/>
|
||||
<attribute name="firstName" attributeType="String" syncable="YES"/>
|
||||
<attribute name="identifier" attributeType="String" syncable="YES"/>
|
||||
<attribute name="lastName" attributeType="String" syncable="YES"/>
|
||||
<relationship name="teams" toMany="YES" deletionRule="Cascade" destinationEntity="Team" inverseName="account" inverseEntity="Team" syncable="YES"/>
|
||||
<uniquenessConstraints>
|
||||
<uniquenessConstraint>
|
||||
<constraint value="identifier"/>
|
||||
</uniquenessConstraint>
|
||||
</uniquenessConstraints>
|
||||
</entity>
|
||||
<entity name="App" representedClassName="App" syncable="YES">
|
||||
<attribute name="developerName" attributeType="String" syncable="YES"/>
|
||||
<attribute name="downloadURL" attributeType="URI" syncable="YES"/>
|
||||
@@ -25,8 +37,21 @@
|
||||
<attribute name="version" attributeType="String" syncable="YES"/>
|
||||
<relationship name="app" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="App" inverseName="installedApp" inverseEntity="App" syncable="YES"/>
|
||||
</entity>
|
||||
<entity name="Team" representedClassName="Team" syncable="YES">
|
||||
<attribute name="identifier" attributeType="String" syncable="YES"/>
|
||||
<attribute name="name" attributeType="String" syncable="YES"/>
|
||||
<attribute name="type" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
|
||||
<relationship name="account" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Account" inverseName="teams" inverseEntity="Account" syncable="YES"/>
|
||||
<uniquenessConstraints>
|
||||
<uniquenessConstraint>
|
||||
<constraint value="identifier"/>
|
||||
</uniquenessConstraint>
|
||||
</uniquenessConstraints>
|
||||
</entity>
|
||||
<elements>
|
||||
<element name="App" positionX="-63" positionY="-18" width="128" height="210"/>
|
||||
<element name="InstalledApp" positionX="-63" positionY="0" width="128" height="120"/>
|
||||
<element name="Team" positionX="-45" positionY="81" width="128" height="105"/>
|
||||
<element name="Account" positionX="-36" positionY="90" width="128" height="120"/>
|
||||
</elements>
|
||||
</model>
|
||||
52
AltStore/Model/Team.swift
Normal file
52
AltStore/Model/Team.swift
Normal file
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// Team.swift
|
||||
// AltStore
|
||||
//
|
||||
// Created by Riley Testut on 5/31/19.
|
||||
// Copyright © 2019 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
import AltSign
|
||||
|
||||
@objc(Team)
|
||||
class Team: NSManagedObject
|
||||
{
|
||||
/* Properties */
|
||||
@NSManaged var name: String
|
||||
@NSManaged var identifier: String
|
||||
@NSManaged var type: ALTTeamType
|
||||
|
||||
/* Relationships */
|
||||
@NSManaged private(set) var account: Account!
|
||||
|
||||
var altTeam: ALTTeam?
|
||||
|
||||
private override init(entity: NSEntityDescription, insertInto context: NSManagedObjectContext?)
|
||||
{
|
||||
super.init(entity: entity, insertInto: context)
|
||||
}
|
||||
|
||||
init(_ team: ALTTeam, account: Account, context: NSManagedObjectContext)
|
||||
{
|
||||
super.init(entity: Team.entity(), insertInto: context)
|
||||
|
||||
self.altTeam = team
|
||||
|
||||
self.name = team.name
|
||||
self.identifier = team.identifier
|
||||
self.type = team.type
|
||||
|
||||
self.account = account
|
||||
}
|
||||
}
|
||||
|
||||
extension Team
|
||||
{
|
||||
@nonobjc class func fetchRequest() -> NSFetchRequest<Team>
|
||||
{
|
||||
return NSFetchRequest<Team>(entityName: "Team")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user