-
Notifications
You must be signed in to change notification settings - Fork 110
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 rootAttributes #557
Conversation
LockTests/Models/UserSpec.swift
Outdated
it("should clear root attributes") { | ||
user.rootAttributes["family_name"] = "Doe" | ||
user.reset() | ||
expect(user.rootAttributes["first_name"]).to(beNil()) |
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.
Is first_name
a typo here, or should it be testing that family_name
is Nil? If not, the intent of the test isn't too clear.
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 think the intent is that he sets a value first, then clears the map, and then checks that the map no longer has that value he first added. So yes, Steve is right and it should be checking against the key added before.
expect(user.rootAttributes["first_name"]).to(beNil()) | |
expect(user.rootAttributes["family_name"]).to(beNil()) |
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.
Yes, was a typo
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.
given that userMetadata is a root profile attribute, would you consider changing the implementation so that all the methods which signatures can be changed now receive a single param named "rootAttributes" instead of "userMetadata" and "rootAttributes"?
When constructing the map with values, the metadata would go into a "user_metadata" key if the map is not empty.
App/ViewController.swift
Outdated
@@ -203,13 +203,15 @@ func applyDefaultOptions(_ options: inout OptionBuildable) { | |||
|
|||
if #available(iOS 10, *) { | |||
options.customSignupFields = [ | |||
CustomTextField(name: "first_name", placeholder: "First Name", icon: LazyImage(name: "ic_person", bundle: Lock.bundle), contentType: .givenName), | |||
CustomTextField(name: "last_name", placeholder: "Last Name", icon: LazyImage(name: "ic_person", bundle: Lock.bundle), contentType: .familyName) | |||
CustomTextField(name: "given_name", placeholder: "First Name", rootAttribute: true, icon: LazyImage(name: "ic_person", bundle: Lock.bundle), contentType: .givenName), |
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 is the sample app, no?
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.
Yes, I use it for testing, will remove these actually in this case.
@@ -350,28 +350,38 @@ class DatabaseInteractorSpec: QuickSpec { | |||
} | |||
|
|||
it("should always store value") { | |||
let _ = try? database.update(.custom(name: "first_name"), value: "Auth0") |
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.
keep one as it was OR add a new test case to test the "default" behavior (still storing into user_metadata, or additional attributes in terms of iOS)
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.
Agree with you. However, these are using mocks so it's not quite the same so I do need to specify.
@@ -303,6 +303,11 @@ class MockAuthentication: Authentication { | |||
} | |||
|
|||
class MockWebAuth: WebAuth { | |||
|
|||
func useLegacyAuthentication(withStyle style: UIModalPresentationStyle) -> Self { |
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.
why is this needed here?
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.
Lock not been updated in a bit, bunch of changes in Auth0.swift as this PR requires latest.
49f727f
to
dda4429
Compare
Changes
Storage for Custom Fields can now be changed to use
rootAttributes
, default isfalse
(non breaking) which means use the existing behaviour of being stored in usermetaData
References
auth0/Auth0.swift#287
Testing
Manually tested as well to check API call output
Checklist