Esempio n. 1
0
        public async Task <Result <Unit> > ActivateAccount(UnverifiedAccount a)
        {
            var u = await _userManager.FindByIdAsync(a.UserId);

            if (u == null)
            {
                return(new Error <Unit>("User not found."));
            }
            else
            {
                var activation = await _userManager.ConfirmEmailAsync(u, a.VerificationCode);

                if (activation.Succeeded)
                {
                    await _signInManager.SignInAsync(u, new AuthenticationProperties());

                    return(new Ok <Unit>(new Unit()));
                }
                else
                {
                    await _signInManager.SignOutAsync();

                    return(activation.ToAppError <Unit>());
                }
            }
        }
Esempio n. 2
0
        public Task <Result <string> > Send(
            HttpResponse r,
            UnverifiedAccount acct)
        {
            r.OnCompleted(() =>
            {
                _logger.LogInformation($"{acct.UserId} {acct.VerificationCode}");
                return(Task.CompletedTask);
            });

            return(Task.FromResult <Result <string> >(new Ok <string>(acct.VerificationCode)));
        }