public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new TRUser { UserName = model.Email, Email = model.Email }; var result = await userManager.CreateAsync(user, model.Password); if (result.Succeeded) { await signInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("Index", "Home")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public async Task <TRUser> Signup(string email, string password) { TRUser result = null; string response = String.Empty; MvxTrace.Trace("Signup with email:{0}, password:{1}", email, password); var request = new { email = email, password = password, provider = TRConstant.TRDefaultOAuthProvider }; try { response = await CallRestAPI(signupMethod, JsonConvert.SerializeObject(request)); result = JsonConvert.DeserializeObject <TRUser>(response, jsonSerializeSetting); } catch (Exception ex) { Xamarin.Insights.Report(ex, new Dictionary <string, string> { { "Exception Time", DateTime.Now.ToString() }, { "Description", "Parse Failed during signup" }, { "Target String", response }, }, Xamarin.Insights.Severity.Error); MvxTrace.Trace("Parse Failed during Signup API Target:{0}", response); } return(result); }
private async void DoSignup() { UserDialogs.Instance.ShowLoading(); TRUser user = await m_TRService.Signup(Email, Password); UserDialogs.Instance.HideLoading(); if (user != null && user.Success) { TRService.Token = user.AccessToken; // Goto Home screen MvxTrace.Trace("Signup success:{0}", user.AccessToken); } else { bool isForgot = await UserDialogs.Instance.ConfirmAsync( "The username or password you entered did not match with our records. Please double-check and try again.", "Please try again...", "Forgot Password?", "OK"); if (isForgot) { UserDialogs.Instance.Alert("Please proceed to your email to receive your password.", "Password Sent"); } } }
public async Task <TRUser> FacebookLogin(FBUserInfo fbUserInfo) { TRUser result = null; string response = String.Empty; MvxTrace.Trace("Facebook Loing with email:{0}", fbUserInfo.UserEmail); fbUserInfo.Provider = TRConstant.TRFBOAuthProvider; string serialized = JsonConvert.SerializeObject(fbUserInfo); try { response = await CallRestAPI(loginMethod, JsonConvert.SerializeObject(fbUserInfo)); result = JsonConvert.DeserializeObject <TRUser>(response, jsonSerializeSetting); } catch (Exception ex) { Xamarin.Insights.Report(ex, new Dictionary <string, string> { { "Exception Time", DateTime.Now.ToString() }, { "Description", "Parse Failed during login" }, { "Target String", response }, }, Xamarin.Insights.Severity.Error); MvxTrace.Trace("Parse Failed during Loing API Target:{0}", response); } return(result); }
private async void DoFacebookSignup(FBUserInfo fbUserInfo) { UserDialogs.Instance.ShowLoading(); TRUser user = await m_TRService.FacebookLogin(fbUserInfo); UserDialogs.Instance.HideLoading(); if (user != null && user.Success) { TRService.Token = user.AccessToken; // Goto Home screen MvxTrace.Trace("Facebook Signup success:{0}", user.AccessToken); } else { UserDialogs.Instance.Alert("Failed to signup using Facebook. Please contact administrator", "ThisRoof", "OK"); } }