コード例 #1
0
        internal async Task <string> InsertOneTimeTokenAsync(string email, OneTimeTokenType tokenType)
        {
            var token = AuthenticationHelper.GenerateRandomString(160);

            await Context.OneTimeTokens.AddAsync(new OneTimeToken
            {
                Email      = email,
                Token      = token,
                TokenType  = (byte)tokenType,
                ValidUntil = DateTime.Now.AddDays(1)
            });

            await Context.SaveChangesAsync();

            return(token);
        }
コード例 #2
0
        internal static async Task <OneTimeToken> AddOneTimeTokenAsync(QuizContext context, string email, OneTimeTokenType tokenType, string token, bool isValid)
        {
            var oneTimeToken = await context.OneTimeTokens.AddAsync(new OneTimeToken
            {
                Email      = email,
                TokenType  = (byte)tokenType,
                Token      = token,
                ValidUntil = DateTime.Now.AddYears(isValid ? 1 : -1)
            });

            return(oneTimeToken.Entity);
        }