Exemplo n.º 1
0
 public Content UpdateContent(ref Content content, int accountId)
 {
     content.Updated           = DateTime.UtcNow;
     content.LastUpdatedUserId = accountId;
     RepositoryContext.Update(content);
     RepositoryContext.SaveChanges();
     return(content);
 }
Exemplo n.º 2
0
        public void RevokeToken(string token, string ipAddress)
        {
            var(refreshToken, account) = getRefreshToken(token);

            // revoke token and save
            refreshToken.Revoked     = DateTime.UtcNow;
            refreshToken.RevokedByIp = ipAddress;
            RepositoryContext.Update(account);
            RepositoryContext.SaveChanges();
        }
Exemplo n.º 3
0
        public void Authenticate(string ipAddress, string secret, ref Account account, out string jwtToken, out RefreshToken refreshToken)
        {
            // authentication successful so generate jwt and refresh tokens
            jwtToken     = generateJwtToken(account, secret);
            refreshToken = generateRefreshToken(ipAddress);

            // save refresh token
            account.RefreshTokens?.Add(refreshToken);
            RepositoryContext.Update(account);
            RepositoryContext.SaveChanges();
        }
Exemplo n.º 4
0
        public Account RefreshToken(string token, string ipAddress, string secret, out string jwtToken, out RefreshToken newRefreshToken)
        {
            var(refreshToken, account) = getRefreshToken(token);

            // replace old refresh token with a new one and save
            newRefreshToken              = generateRefreshToken(ipAddress);
            refreshToken.Revoked         = DateTime.UtcNow;
            refreshToken.RevokedByIp     = ipAddress;
            refreshToken.ReplacedByToken = newRefreshToken.Token;
            account.RefreshTokens.Add(newRefreshToken);
            RepositoryContext.Update(account);
            RepositoryContext.SaveChanges();

            // generate new jwt
            jwtToken = generateJwtToken(account, secret);
            return(account);
        }
Exemplo n.º 5
0
 public void uptdate <T>(T entity) where T : class
 {
     _context.Update(entity);
 }