-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for root attributes when creating a new user #287
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,7 +155,7 @@ public protocol Authentication: Trackable, Loggable { | |
.start { print($0) } | ||
``` | ||
|
||
you can also add additional attributes when creating the user | ||
you can also add additional metadata when creating the user | ||
lbalmaceda marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
``` | ||
Auth0 | ||
|
@@ -178,10 +178,12 @@ public protocol Authentication: Trackable, Loggable { | |
- parameter password: password for the new user | ||
- parameter connection: name where the user will be created (Database connection) | ||
- parameter userMetadata: additional userMetadata parameters that will be added to the newly created user. | ||
|
||
- parameter rootAttributes: root attributes that will be added to the newly created user. See https://auth0.com/docs/api/authentication#signup for supported attributes. Will not overwrite existing parameters. | ||
|
||
- returns: request that will yield a created database user (just email, username and email verified flag) | ||
*/ | ||
func createUser(email: String, username: String?, password: String, connection: String, userMetadata: [String: Any]?) -> Request<DatabaseUser, AuthenticationError> | ||
// swiftlint:disable:next function_parameter_count | ||
func createUser(email: String, username: String?, password: String, connection: String, userMetadata: [String: Any]?, rootAttributes: [String: Any]?) -> Request<DatabaseUser, AuthenticationError> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. protocols' methods can be changed without breaking users? this is a public one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like an optional argument, and it's placed at the end of the parameter list so I'm not sure it would be a breaking change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The argument is optional so in use you don't need to specify it. However, Lucho is correct any class that implements the protocol still has to support the behaviour. As the Protocol is Public then we should try to avoid breaking it. I'll add support for this in the Public Extension so the original method will still work out of the box as the method in the Public Extension is a fallback. |
||
|
||
/** | ||
Resets a Database user password | ||
|
@@ -632,11 +634,27 @@ public extension Authentication { | |
- parameter password: password for the new user | ||
- parameter connection: name where the user will be created (Database connection) | ||
- parameter userMetadata: additional userMetadata parameters that will be added to the newly created user. | ||
- parameter rootAttributes: root attributes that will be added to the newly created user. See https://auth0.com/docs/api/authentication#signup for supported attributes. Will not overwrite existing parameters. | ||
|
||
- returns: request that will yield a created database user (just email, username and email verified flag) | ||
*/ | ||
func createUser(email: String, username: String? = nil, password: String, connection: String, userMetadata: [String: Any]? = nil, rootAttributes: [String: Any]? = nil) -> Request<DatabaseUser, AuthenticationError> { | ||
return self.createUser(email: email, username: username, password: password, connection: connection, userMetadata: userMetadata, rootAttributes: rootAttributes) | ||
} | ||
|
||
/** | ||
Creates a user in a Database connection | ||
|
||
- parameter email: email of the user to create | ||
- parameter username: username of the user if the connection requires username. By default is 'nil' | ||
- parameter password: password for the new user | ||
- parameter connection: name where the user will be created (Database connection) | ||
- parameter userMetadata: additional userMetadata parameters that will be added to the newly created user. | ||
|
||
- returns: request that will yield a created database user (just email, username and email verified flag) | ||
*/ | ||
func createUser(email: String, username: String? = nil, password: String, connection: String, userMetadata: [String: Any]? = nil) -> Request<DatabaseUser, AuthenticationError> { | ||
return self.createUser(email: email, username: username, password: password, connection: connection, userMetadata: userMetadata) | ||
return self.createUser(email: email, username: username, password: password, connection: connection, userMetadata: userMetadata, rootAttributes: nil) | ||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this behavior should be clarified in the method documentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems fair, it was intended to stop abuse like overwriting of core params
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's no abuse IMHO. The user should be free to send whatever they want as "additional params". If they send something we already specify, that's their fault.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you in principal.