示例#1
0
        //
        // POST: /Account/SendLogInLink
        public IActionResult SendLogInLink(SendLogInLinkModel model)
        {
            if (ModelState.IsValid)
            {
                model.Send(Url);
                this.SetResultMessage($"A log in link will be sent to {model.Email}.");
            }

            return(RedirectToAction("Index", "Home"));
        }
示例#2
0
    public IActionResult Index()
    {
        if (User?.Identity?.IsAuthenticated == true)
        {
            return(RedirectToAction("Dashboard", "Home"));
        }

        var model = new SendLogInLinkModel();

        return(View(model));
    }
示例#3
0
    public async Task <IActionResult> SendLogInLink(SendLogInLinkModel model, CancellationToken token = default)
    {
        if (ModelState.IsValid)
        {
            var accounts = await _accountRepository.GetAllAsync(token);

            var account = accounts.SingleOrDefault(a => a.Email?.Equals(model.Email, StringComparison.OrdinalIgnoreCase) ?? false);

            if (account is null && _appSettings.AdminEmail.Equals(model.Email, StringComparison.OrdinalIgnoreCase))
            {
                account = await CreateAdminUser(token);
            }

            await SendLogInEmail(account, token);
        }

        this.SetResultMessage($"A log in link will be sent to {model.Email}.");
        return(RedirectToAction("Index", "Home"));
    }