src/fursvp.api/Controllers/AuthController.cs
/// <summary>
/// Sends a verification email and caches the verification code.
/// </summary>
/// <param name="sendVerificationCodeRequest">The email address to log in as.</param>
/// <returns>An OkResult on success or BadRequestResult on failure.</returns>
Sends a verification email and caches the verification code.
Sends a verification email and caches the verification code .
[HttpPost]
        [Route("sendverificationcode")]
        public async Task<IActionResult> SendVerificationCode([FromBody]SendVerificationCodeRequest sendVerificationCodeRequest)
        {
            if (sendVerificationCodeRequest == null)
            {
                return BadRequest();
            }
            var verificationCodeCacheKey = VerificationCodeCacheKey(sendVerificationCodeRequest.EmailAddress);
            string verificationCode = FursvpRandom.CopyableButHardToGuessCode();
            MemoryCache.Set(verificationCodeCacheKey, verificationCode, TimeSpan.FromMinutes(60)); 
            var email = CreateVerificationEmail(sendVerificationCodeRequest.EmailAddress, verificationCode);
            await Emailer.SendAsync(email).ConfigureAwait(false);
            return Ok();
        }
[ HttpPost ] [ Route ( " " ) ] public async Task < IActionResult > SendVerificationCode ( [ FromBody ] SendVerificationCodeRequest sendVerificationCodeRequest ) { if ( sendVerificationCodeRequest == null ) { return BadRequest ( ) ; } var verificationCodeCacheKey = VerificationCodeCacheKey ( sendVerificationCodeRequest . EmailAddress ) ; string verificationCode = FursvpRandom . CopyableButHardToGuessCode ( ) ; MemoryCache . Set ( verificationCodeCacheKey , verificationCode , TimeSpan . FromMinutes ( 60 ) ) ; var email = CreateVerificationEmail ( sendVerificationCodeRequest . EmailAddress , verificationCode ) ; await Emailer . SendAsync ( email ) . ConfigureAwait ( false ) ; return Ok ( ) ; }
Sends a verification email and caches the verification code.
Sends a verification email and caches the verification code .
// TODO - make this a config variable
An OkResult on success or BadRequestResult on failure.
An OkResult on success or BadRequestResult on failure .
SendVerificationCodeRequest
[FromBody]
sendVerificationCodeRequest
The email address to log in as.
The email address to log in as .