public async Task <LoginResult> AuthenticateAsync(FacebookAccount account, RemoteUser user) { var facebookUser = this.GetFacebookUserInfo(account.Token); if (!this.Validate(facebookUser, account.FacebookUserId, account.Email)) { return(new LoginResult { Status = false, Message = Resources.AccessIsDenied }); } var result = await FacebookSignIn.SignInAsync(this.Tenant, account.FacebookUserId, account.Email, account.OfficeId, facebookUser.Name, account.Token, user.Browser, user.IpAddress, account.Culture) .ConfigureAwait(false); if (result.Status) { if (!await Registrations.HasAccountAsync(this.Tenant, account.Email).ConfigureAwait(false)) { string template = "~/Tenants/{tenant}/Areas/Frapid.Account/EmailTemplates/welcome-email-other.html"; var welcomeEmail = new WelcomeEmail(facebookUser, template, this.ProviderName); await welcomeEmail.SendAsync(this.Tenant).ConfigureAwait(false); } } return(result); }
public async Task <LoginResult> AuthenticateAsync(GoogleAccount account, RemoteUser user) { bool validationResult = Task.Run(() => this.ValidateAsync(account.Token)).GetAwaiter().GetResult(); if (!validationResult) { return(new LoginResult { Status = false, Message = Resources.AccessIsDenied }); } var gUser = new GoogleUserInfo { Email = account.Email, Name = account.Name }; var result = await GoogleSignIn.SignInAsync(this.Tenant, account.Email, account.OfficeId, account.Name, account.Token, user.Browser, user.IpAddress, account.Culture).ConfigureAwait(false); if (result.Status) { if (!await Registrations.HasAccountAsync(this.Tenant, account.Email).ConfigureAwait(false)) { string template = "~/Tenants/{tenant}/Areas/Frapid.Account/EmailTemplates/welcome-email-other.html"; var welcomeEmail = new WelcomeEmail(gUser, template, ProviderName); await welcomeEmail.SendAsync(this.Tenant).ConfigureAwait(false); } } return(result); }
public async Task <LoginResult> AuthenticateAsync(GoogleAccount account, RemoteUser user) { bool validationResult = Task.Run(() => ValidateAsync(account.Token)).Result; if (!validationResult) { return(new LoginResult { Status = false, Message = "Access is denied" }); } var gUser = new GoogleUserInfo { Email = account.Email, Name = account.Name }; var result = GoogleSignIn.SignIn(account.Email, account.OfficeId, account.Name, account.Token, user.Browser, user.IpAddress, account.Culture); if (result.Status) { if (!Registrations.HasAccount(account.Email)) { string template = "~/Catalogs/{catalog}/Areas/Frapid.Account/EmailTemplates/welcome-email-other.html"; var welcomeEmail = new WelcomeEmail(gUser, template, ProviderName); await welcomeEmail.SendAsync(); } } return(result); }
public async Task <LoginResult> AuthenticateAsync(FacebookAccount account, RemoteUser user) { FacebookUserInfo facebookUser = GetFacebookUserInfo(account.Token); if (!Validate(facebookUser, account.FacebookUserId, account.Email)) { return(new LoginResult { Status = false, Message = "Access is denied" }); } LoginResult result = FacebookSignIn.SignIn(account.FacebookUserId, account.Email, account.OfficeId, facebookUser.Name, account.Token, user.Browser, user.IpAddress, account.Culture); if (result.Status) { if (!Registration.HasAccount(account.Email)) { string template = "~/Catalogs/{catalog}/Areas/Frapid.Account/EmailTemplates/welcome-3rd-party.html"; WelcomeEmail welcomeEmail = new WelcomeEmail(facebookUser, template, ProviderName); await welcomeEmail.SendAsync(); } } return(result); }
public async Task <ActionResult> ConfirmAsync(string token) { Guid id = token.To <Guid>(); if (!DAL.Registration.ConfirmRegistration(id)) { return(View(GetRazorView <AreaRegistration>("SignUp/InvalidToken.cshtml"))); } DTO.Registration registration = DAL.Registration.Get(id); WelcomeEmail email = new WelcomeEmail(registration); await email.SendAsync(); return(View(GetRazorView <AreaRegistration>("SignUp/Welcome.cshtml"))); }
public async Task <ActionResult> ConfirmAsync(string token) { var id = token.To <Guid>(); if (!Registrations.ConfirmRegistration(id)) { return(this.View(this.GetRazorView <AreaRegistration>("SignUp/InvalidToken.cshtml"))); } var registration = Registrations.Get(id); var email = new WelcomeEmail(registration); await email.SendAsync(); return(this.View(this.GetRazorView <AreaRegistration>("SignUp/Welcome.cshtml"))); }
public ActionResult Register(RegisterViewModel model) { if (_userService.EmailInUse(model.Email)) { ModelState.AddModelErrorFor <RegisterViewModel>(m => m.Email, "Email is already in use by another user."); } if (IsModelValidAndPersistErrors()) { User user = _userService.Register(model.Email, model.Password, Request.UserHostAddress); SetSuccess("Account successfully created."); WelcomeEmail welcomeEmail = Emailer.Welcome(user.Email, model.Password, Url.Action("Login", "Security")); welcomeEmail.SendAsync(); return(RedirectToAction("Login")); } return(RedirectToSelf()); }
public async Task <ActionResult> ConfirmAsync(string token) { if (RemoteUser.IsListedInSpamDatabase(this.Tenant)) { return(this.View(this.GetRazorView <AreaRegistration>("ListedInSpamDatabase.cshtml", this.Tenant))); } var id = token.To <Guid>(); if (!await Registrations.ConfirmRegistrationAsync(this.Tenant, id).ConfigureAwait(true)) { return(this.View(this.GetRazorView <AreaRegistration>("SignUp/InvalidToken.cshtml", this.Tenant))); } var registration = await Registrations.GetAsync(this.Tenant, id).ConfigureAwait(true); var email = new WelcomeEmail(registration); await email.SendAsync(this.Tenant).ConfigureAwait(true); return(this.View(this.GetRazorView <AreaRegistration>("SignUp/Welcome.cshtml", this.Tenant))); }