-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add reset and update password for end users (#120)
- Loading branch information
Showing
12 changed files
with
309 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// UserResetPasswordParams.swift | ||
// OmiseGO | ||
// | ||
// Created by Mederic Petit on 14/3/19. | ||
// Copyright © 2019 Omise Go Pte. Ltd. All rights reserved. | ||
// | ||
|
||
/// Represents a structure used to request a password reset for the user | ||
public struct UserResetPasswordParams { | ||
/// The email of the user | ||
public let email: String | ||
/// The URL where the user will be taken when clicking the link in the email | ||
public let redirectUrl: String | ||
|
||
/// Initialize the params used to request a password reset for the user | ||
/// | ||
/// - Parameters: | ||
/// - email: The email of the user | ||
/// - redirectUrl: The URL where the user will be taken when clicking the link in the email | ||
public init(email: String, | ||
redirectUrl: String) { | ||
self.email = email | ||
self.redirectUrl = redirectUrl | ||
} | ||
} | ||
|
||
extension UserResetPasswordParams: APIParameters { | ||
private enum CodingKeys: String, CodingKey { | ||
case email | ||
case redirectUrl = "redirect_url" | ||
} | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
var container = encoder.container(keyedBy: CodingKeys.self) | ||
try container.encode(email, forKey: .email) | ||
try container.encode(redirectUrl, forKey: .redirectUrl) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// | ||
// UserUpdatePasswordParams.swift | ||
// OmiseGO | ||
// | ||
// Created by Mederic Petit on 14/3/19. | ||
// Copyright © 2019 Omise Go Pte. Ltd. All rights reserved. | ||
// | ||
|
||
/// Represents a structure used to update the password of a user following a reset | ||
public struct UserUpdatePasswordParams { | ||
/// The email of the user (obtained from the params in the link sent to the email of the user) | ||
public let email: String | ||
/// The unique reset password token obtained from the params in the link sent to the email of the user | ||
public let token: String? | ||
/// The updated password | ||
public let password: String | ||
/// The password confirmation that should match the updated password | ||
public let passwordConfirmation: String | ||
|
||
/// Initialize the params used to signup a user | ||
/// | ||
/// - Parameters: | ||
/// - email: The email of the user (obtained from the params in the link sent to the email of the user) | ||
/// - token: The unique reset password token obtained from the params in the link sent to the email of the user | ||
/// - password: The updated password | ||
/// - passwordConfirmation: The password confirmation that should match the updated password | ||
public init(email: String, | ||
token: String, | ||
password: String, | ||
passwordConfirmation: String) { | ||
self.email = email | ||
self.token = token | ||
self.password = password | ||
self.passwordConfirmation = passwordConfirmation | ||
} | ||
} | ||
|
||
extension UserUpdatePasswordParams: APIParameters { | ||
private enum CodingKeys: String, CodingKey { | ||
case email | ||
case token | ||
case password | ||
case passwordConfirmation = "password_confirmation" | ||
} | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
var container = encoder.container(keyedBy: CodingKeys.self) | ||
try container.encode(email, forKey: .email) | ||
try container.encode(token, forKey: .token) | ||
try container.encode(password, forKey: .password) | ||
try container.encode(passwordConfirmation, forKey: .passwordConfirmation) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
Tests/Client/FixtureTests/client_fixtures/api/user.reset_password.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"version": "1", | ||
"success": true, | ||
"data": {} | ||
} |
5 changes: 5 additions & 0 deletions
5
Tests/Client/FixtureTests/client_fixtures/api/user.update_password.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"version": "1", | ||
"success": true, | ||
"data": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.