@@ -7,33 +7,36 @@ import SotoCognitoIdentityProvider
77import SotoCognitoIdentity
88import Dependencies
99
10- enum VerifyController {
11- @Sendable
12- static func show( req: Request ) async throws -> HTML {
13- return Verify . View ( path: req. url. path, model: Verify . Model ( email: " " ) ) . document ( )
14- }
10+ extension Portal {
1511
16- @Sendable
17- static func verify( req: Request ) async throws -> HTML {
18- @Dependency ( \. cognito) var cognito
19- struct VerifyInformation : Content {
20- var email : String
21- var confirmationCode : String
12+ enum VerifyController {
13+ @Sendable
14+ static func show( req: Request ) async throws -> HTML {
15+ return Verify . View ( path: req. url. path, model: Verify . Model ( email: " " ) ) . document ( )
2216 }
23- do {
24- let info = try req. content. decode ( VerifyInformation . self)
25- try await cognito. confirmSignUp ( req: req, username: info. email, confirmationCode: info. confirmationCode)
26- let model = SuccessfulChange . Model ( successMessage: " Successfully confirmed signup " )
27- return SuccessfulChange . View ( path: req. url. path, model: model) . document ( )
28- } catch let error as AWSErrorType {
29- let info = try req. content. decode ( VerifyInformation . self)
30- let errorMessage = ( error. message != nil ) ? " There was an error: \( error. message) " : " There was an error: \( error. localizedDescription) "
31- let model = Verify . Model ( email: info. email, errorMessage: errorMessage)
32- return Verify . View ( path: req. url. path, model: model) . document ( )
33- } catch {
34- let info = try req. content. decode ( VerifyInformation . self)
35- let model = Verify . Model ( email: info. email, errorMessage: " An unknown error occurred: \( error. localizedDescription) " )
36- return Verify . View ( path: req. url. path, model: model) . document ( )
17+
18+ @Sendable
19+ static func verify( req: Request ) async throws -> HTML {
20+ @Dependency ( \. cognito) var cognito
21+ struct VerifyInformation : Content {
22+ var email : String
23+ var confirmationCode : String
24+ }
25+ do {
26+ let info = try req. content. decode ( VerifyInformation . self)
27+ try await cognito. confirmSignUp ( req: req, username: info. email, confirmationCode: info. confirmationCode)
28+ let model = SuccessfulChange . Model ( successMessage: " Successfully confirmed signup " )
29+ return SuccessfulChange . View ( path: req. url. path, model: model) . document ( )
30+ } catch let error as AWSErrorType {
31+ let info = try req. content. decode ( VerifyInformation . self)
32+ let errorMessage = ( error. message != nil ) ? " There was an error: \( error. message) " : " There was an error: \( error. localizedDescription) "
33+ let model = Verify . Model ( email: info. email, errorMessage: errorMessage)
34+ return Verify . View ( path: req. url. path, model: model) . document ( )
35+ } catch {
36+ let info = try req. content. decode ( VerifyInformation . self)
37+ let model = Verify . Model ( email: info. email, errorMessage: " An unknown error occurred: \( error. localizedDescription) " )
38+ return Verify . View ( path: req. url. path, model: model) . document ( )
39+ }
3740 }
3841 }
3942}
0 commit comments