Skip to content

Commit bfc47df

Browse files
committed
add source and remoteid for OAuth2 capacity
1 parent 0bb1dfb commit bfc47df

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

Sources/LocalAuthentication/Schema/Account.swift

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public class Account: PostgresStORM {
1717
public var password = ""
1818
public var email = ""
1919
public var usertype: AccountType = .provisional
20+
public var source = "local" // local, facebook, etc
21+
public var remoteid = "" // if oauth then the sourceid is stored here
2022
public var passvalidation = ""
2123
public var detail = [String:Any]()
2224

@@ -28,7 +30,9 @@ public class Account: PostgresStORM {
2830
password = this.data["password"] as? String ?? ""
2931
email = this.data["email"] as? String ?? ""
3032
usertype = AccountType.from((this.data["usertype"] as? String)!)
31-
passvalidation = this.data["passvalidation"] as? String ?? ""
33+
source = this.data["source"] as? String ?? "local"
34+
remoteid = this.data["remoteid"] as? String ?? ""
35+
passvalidation = this.data["passvalidation"] as? String ?? ""
3236
if let detailObj = this.data["detail"] {
3337
self.detail = detailObj as? [String:Any] ?? [String:Any]()
3438
}
@@ -48,14 +52,24 @@ public class Account: PostgresStORM {
4852
super.init()
4953
}
5054

51-
public init(_ i: String = "", _ u: String, _ p: String = "", _ e: String, _ ut: AccountType = .provisional) {
55+
public init(
56+
_ i: String = "",
57+
_ u: String,
58+
_ p: String = "",
59+
_ e: String,
60+
_ ut: AccountType = .provisional,
61+
_ s: String = "local",
62+
_ rid: String = ""
63+
) {
5264
super.init()
5365
id = i
5466
username = u
5567
password = p
5668
email = e
5769
usertype = ut
5870
passvalidation = _r.secureToken
71+
source = s
72+
remoteid = rid
5973
}
6074

6175
public init(validation: String) {
@@ -160,6 +174,8 @@ public class Account: PostgresStORM {
160174
r["email"] = row.email
161175
r["usertype"] = row.usertype
162176
r["detail"] = row.detail
177+
r["source"] = row.source
178+
r["remoteid"] = row.remoteid
163179
users.append(r)
164180
}
165181
return users

0 commit comments

Comments
 (0)