Exemplo n.º 1
0
        public async Task<LoginResult> AuthenticateAsync(FacebookAccount account, RemoteUser user)
        {
            var facebookUser = GetFacebookUserInfo(account.Token);

            if (!Validate(facebookUser, account.FacebookUserId, account.Email))
            {
                return new LoginResult
                {
                    Status = false,
                    Message = "Access is denied"
                };
            }

            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, ProviderName);
                    await welcomeEmail.SendAsync(this.Tenant).ConfigureAwait(false);
                }
            }
            return result;
        }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        public async Task<ActionResult> ConfirmAsync(string token)
        {
            var id = token.To<Guid>();

            if (!DAL.Registrations.ConfirmRegistration(id))
            {
                return this.View(this.GetRazorView<AreaRegistration>("SignUp/InvalidToken.cshtml"));
            }

            var registration = DAL.Registrations.Get(id);
            var email = new WelcomeEmail(registration);
            await email.SendAsync();

            return this.View(this.GetRazorView<AreaRegistration>("SignUp/Welcome.cshtml"));
        }
Exemplo n.º 4
0
        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));
        }