Exemplo n.º 1
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.º 2
0
 public async Task<ActionResult> GoogleSignInAsync(GoogleAccount account)
 {
     try
     {
         var oauth = new GoogleAuthentication(this.Tenant);
         var result = await oauth.AuthenticateAsync(account, this.RemoteUser).ConfigureAwait(false);
         return await this.OnAuthenticatedAsync(result).ConfigureAwait(true);
     }
     catch(NpgsqlException)
     {
         return this.AccessDenied();
     }
 }
 public async Task<ActionResult> GoogleSignInAsync(GoogleAccount account)
 {
     try
     {
         var oauth = new GoogleAuthentication();
         var result =
             await oauth.AuthenticateAsync(account, this.RemoteUser);
         return OnAuthenticated(result);
     }
     catch (NpgsqlException)
     {
         return Json("Access is denied.");
     }
 }