This repository was archived by the owner on Apr 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
This repository was archived by the owner on Apr 17, 2019. It is now read-only.
Better API for auth #79
Copy link
Copy link
Closed
Description
Our app accepts both login with username and email address.
I currently need to do in our app:
NSString *user = self.usernameEmailTextField.text;
NSString *password = self.passwordTextField.text;
void (^meteorCallback)(NSDictionary *response, NSError *error);
meteorCallback = ^(NSDictionary *response, NSError *error) {
if (error) {
[self handleFailedAuth:error];
} else {
[self handleSuccessfulAuth];
}
};
if ([CLAHelper validEmail:user]) {
// Without userParameters, ObjectiveDDP user email address
[[CLAMeteorClient sharedClient] logonWithUsername:user password:password responseCallback:meteorCallback];
} else {
NSDictionary *userParameters = @{@"user": @{@"username": user}};
[[CLAMeteorClient sharedClient] logonWithUserParameters:userParameters username:user password:password responseCallback:meteorCallback];
}The current API is not really well designed to accept both types (email and username).
IMO, we should create a new method called:
- (void)logonWithUser:(NSString *)user password:(NSString *)password responseCallback:(MeteorClientMethodCallback)responseCallback;
And detect in there if we need to create a login using email or username (like I did in the first snippet above).
That would be 100% in line with http://docs.meteor.com/#meteor_loginwithpassword
user Object or String
Either a string interpreted as a username or an email; or an object with a single key: email, username or id.
I'm willing to contribute @boundsj and PR if you give me the green light about this, thanks!
Metadata
Metadata
Assignees
Labels
No labels