public AuthToken GetNewTokenForUser(ApiUser user) { string key = user.Secret; string data = user.UserName + user.Password + user.GetHashCode() + randomGen.Next(); string hash = _hashProvider.GetHash(key, data); var resultToken = new AuthToken { Value = hash, ApiUser = user, Expiration = DateTime.Now.AddMinutes(DEFAULT_TOKEN_TIME_IN_MINUTES), IsActive = true }; _tokenRespository.Add(resultToken); return resultToken; }
public AuthToken GetActiveTokenForUser(ApiUser user) { AuthToken activeToken = _tokenRespository.Get(token => token.IsActive).FirstOrDefault(); return activeToken; }