Created
April 13, 2012 00:43
-
-
Save ericktai/2372383 to your computer and use it in GitHub Desktop.
Forgot and Reset Password for the JS SDK
This file contains hidden or 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
StackMobCommon.getStackMobInstance().forgotPassword("johndoe", new StackMobCallback() { | |
@Override public void success(String response) { | |
//forgotPassword succeeded | |
} | |
@Override public void failure(StackMobException e) { | |
//forgotPassword failed | |
} | |
}); |
This file contains hidden or 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
var user = new StackMob.User({ username: 'Chuck Norris' }); | |
//assume StackMob.User has an "email" field, and Chuck Norris's email is "[email protected]" | |
user.forgotPassword(); //tells StackMob to send an email to Chuck Norris at "[email protected]" |
This file contains hidden or 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
[[StackMob stackmob] forgotPasswordByUser:username andCallback:^(BOOL success, id result) { | |
if (success) { | |
// forgotPassword succeeded | |
} else { | |
// forgotPassword failed | |
} | |
}]; |
This file contains hidden or 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
Map<String, String> args = new HashMap<String, String>(); | |
args.put("username", "johndoe"); | |
args.put("password", "tempPassword"); | |
args.put("new_password", "newPassword"); | |
StackMobCommon.getStackMobInstance().login(args, new StackMobCallback() { | |
@Override public void success(String response) { | |
//login succeeded | |
} | |
@Override public void failure(StackMobException e) { | |
//login failed | |
} | |
}); |
This file contains hidden or 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
var user = new StackMob.User({ username: 'Chuck Norris' }); | |
user.forgotPassword(); | |
//after checking getting his temp password in his email... | |
user.loginWithTempAndSetNewPassword('temporary password from StackMob email', 'mysuperfists'); | |
... | |
StackMob.getLoggedInUser(); //returns 'Chuck Norris' | |
//StackMob will log the user in with the temporary password and then give the user a new password: 'mysuperfists' for future logins |
This file contains hidden or 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
NSString *username = @"[USERNAME]" | |
NSString *tempPassword = @"[PASSWORD]" | |
NSString *newPassword = @"[PASSWORD]" | |
NSDictionary *args = [NSDictionary dictionaryWithObjectsAndKeys:username, @"username", tempPassword, @"password", newPassword, @"new_password" nil]; | |
[[StackMob stackmob] loginWithArguments:args andCallback:^(BOOL success, id result) { | |
if (success) { | |
// Login Succeeded | |
} else { | |
// Login Failed | |
} | |
}]; |
This file contains hidden or 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
StackMobCommon.getStackMobInstance().resetPassword("oldPassword", "newPassword", new StackMobCallback() { | |
@Override public void success(String response) { | |
//forgotPassword succeeded | |
} | |
@Override public void failure(StackMobException e) { | |
//forgotPassword failed | |
} | |
}) |
This file contains hidden or 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
var user = new StackMob.User({ username: 'Chuck Norris', password: 'myfists' }); | |
user.login(); | |
... | |
user.resetPassword('myfists', 'mynewandimprovedfists'); //changes password from 'myfists' to 'mynewandimprovedfists' |
This file contains hidden or 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
[[StackMob stackmob] resetPasswordWithOldPassword:@"oldPassword" newPassword:@"newPassword" andCallback:^(BOOL success, id result) { | |
if (success) { | |
// resetPassword succeeded | |
} else { | |
// resetPassword failed | |
} | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment