Skip to content

Commit 4a81225

Browse files
committed
duplicate email check in registration
1 parent 85550bc commit 4a81225

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

Sources/LocalAuthentication/Schema/Account.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,13 @@ public class Account: PostgresStORM {
8080
let this = Account()
8181
do {
8282
try this.find(["email":email])
83-
if this.results.foundSetCount > 0 {
84-
throw OAuth2ServerError.registerError
83+
if this.results.cursorData.totalRecords > 0 {
84+
// print("failing unique test")
85+
throw OAuth2ServerError.invalidEmail
8586
}
8687
} catch {
87-
print(error)
88+
// print(error)
89+
throw OAuth2ServerError.invalidEmail
8890
}
8991
}
9092

@@ -94,6 +96,7 @@ public class Account: PostgresStORM {
9496
let acc = Account(r.secureToken, u, "", e, ut)
9597
do {
9698
try acc.isUnique()
99+
// print("passed unique test")
97100
try acc.create()
98101
} catch {
99102
print(error)
@@ -180,3 +183,4 @@ public enum AccountType {
180183
}
181184
}
182185
}
186+

Sources/LocalAuthentication/Schema/Errors.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
//
88

99
public enum OAuth2ServerError: Error {
10-
case noError, registerError, loginError
10+
case noError, registerError, loginError, invalidEmail
1111
}
12+

0 commit comments

Comments
 (0)