public string GenerateNewAccountConfirmationToken(DateTime whenRequested, TimeSpan duration) { var token = this.SecurityTokenMappings.FirstOrDefault(m => m.WhenUsed == null && m.WhenExpires >= whenRequested && m.Purpose == SecurityTokenMapping.SecurityTokenPurpose.AccountConfirmation); if (token != null) { return(token.Token); } token = new SecurityTokenMapping(Guid.NewGuid(), SecurityTokenMapping.SecurityTokenPurpose.AccountConfirmation, whenRequested, whenRequested.Add(duration)); this._securityTokenMappings.Add(token); return(token.Token); }
public string GenerateNewPasswordResetToken(DateTime whenRequest, TimeSpan duration) { var token = this._securityTokenMappings.FirstOrDefault(m => m.WhenUsed == null && m.WhenExpires >= whenRequest && m.Purpose == SecurityTokenMapping.SecurityTokenPurpose.PasswordReset); if (token != null) { return(token.Token); } token = new SecurityTokenMapping(Guid.NewGuid(), SecurityTokenMapping.SecurityTokenPurpose.PasswordReset, whenRequest, whenRequest.Add(duration)); this._securityTokenMappings.Add(token); return(token.Token); }