Exemplo n.º 1
0
        public async Task <Credential> CreateCredential(LoginCredentialDto loginCredential)
        {
            Credential credentialDb;

            if (loginCredential.GrantType.ToLower().Equals("refreshtoken"))
            {
                refreshToken = loginCredential.RefreshToken;
                logsheet     = await unitOfWork.Logsheet.FindLogsheetByRefreshTokenAsync(refreshToken);

                if (logsheet != null && logsheet.Credential != null)
                {
                    credential = logsheet.Credential;
                    credential.IsAuthenticated = true;
                }
            }
            else if (loginCredential.GrantType.ToLower().Equals("idtoken"))
            {
                credentialDb = unitOfWork.Credential.FindByEmail(loginCredential.Email);
                if (credentialDb != null && StringHelper.CompareStringToHash(credentialDb.Password, loginCredential.Password))
                {
                    credential = credentialDb;
                    credential.IsAuthenticated = true;
                }
            }
            return(credential);
        }
Exemplo n.º 2
0
 public AuthTokenDto Login(Client client, Credential credential)
 {
     if (refreshToken == null)
     {
         refreshToken = tokenSrvice.GenerateRefreshToken(credential.PublicId);
         logsheet     = new Logsheet()
         {
             RefreshToken = refreshToken,
             CredentialId = credential.Id,
             ClientId     = client.Id,
             Platform     = client.Platform,
             Browser      = client.Browser,
             IP           = client.IP,
             CreatedAt    = DateTime.Now,
             UpdatedAt    = DateTime.Now
         };
         unitOfWork.Logsheet.Add(logsheet);
     }
     else
     {
     }
     unitOfWork.Credential.UpdateLastLogin(credential);
     unitOfWork.Logsheet.UpdateLastTimeLogin(logsheet);
     unitOfWork.Complete();
     return(tokenSrvice.GenerateAuthToken(credential, logsheet.Id, refreshToken));
 }
Exemplo n.º 3
0
 public void SetExchquerWorkOrder(Logsheet logsheet = null)
 {
 }