Permalink
Browse files

Make SCAuth login correctly with an email address

  • Loading branch information...
1 parent 98aac6c commit 531a8e0df212dfaa26486c8ac6f9342c2920894e @benlangfeld committed Oct 27, 2010
Showing with 31 additions and 0 deletions.
  1. +31 −0 Client/Frameworks/SCAuth/LoginProviders/SCEmailLoginDialogController.j
@@ -40,4 +40,35 @@ var DefaultLoginDialogController = nil;
DefaultLoginDialogController = [self newLoginDialogController];
return DefaultLoginDialogController;
}
+
+/* @ignore */
+- (void)_loginUser:(CPString)username password:(CPString)password
+{
+ var shouldRemember = ([_rememberMeButton state] === CPOnState);
+ var loginObject = {'user' : {'email' : username, 'password' : password, 'remember' : shouldRemember}};
+ var request = [CPURLRequest requestWithURL:[[CPBundle mainBundle] objectForInfoDictionaryKey:@"SCAuthLoginURL"] || @"/session/"];
+
+ [request setHTTPMethod:@"POST"];
+ [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
+ [request setHTTPBody:[CPString JSONFromObject:loginObject]];
+ _loginConnection = [_connectionClass connectionWithRequest:request
+ delegate:self];
+ _loginConnection.username = username;
+}
+
+/* @ignore */
+- (void)_registerUser:(CPString)username password:(CPString)password
+{
+ var shouldRemember = ([_rememberMeButton state] === CPOnState);
+ var registerObject = {'user' : {'email' : username, 'password' : password, 'remember' : shouldRemember}};
+ var request = [CPURLRequest requestWithURL:[[CPBundle mainBundle] objectForInfoDictionaryKey:@"SCAuthRegistrationURL"] || @"/user/"];
+
+ [request setHTTPMethod:@"POST"];
+ [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
+ [request setHTTPBody:[CPString JSONFromObject:registerObject]];
+ _registrationConnection = [_connectionClass connectionWithRequest:request
+ delegate:self];
+ _registrationConnection.username = username;
+}
+
@end

0 comments on commit 531a8e0

Please sign in to comment.