public async Task <IActionResult> OnGetVerifyAsync(string id, string code)
        {
            var _user = await _db.UserTable.FirstOrDefaultAsync(q => q.Id == id);

            if (!await _manager.IsEmailConfirmedAsync(_user))
            {
                var _result = await _manager.ConfirmEmailAsync(_user, code);

                if (_result != IdentityResult.Success)
                {
                    return(NotFound());
                }

                var _msg = $@"Thank you for registering with <strong>eWallet</strong>.
                    We hope you find your time here enjoyable.";

                var _admin = await _manager.FindByEmailAsync("*****@*****.**");

                await _db.SaveChangesAsync();

                await _sign.SignInAsync(_user, true);

                return(RedirectToPage("./accountConfirmed"));
            }
            return(NotFound());
        }
Exemple #2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid)
            {
                var _originalUser = await _db.UserTable.FirstOrDefaultAsync(m => m.Id == _manager.GetUserId(User));

                _originalUser.fullName    = _form.fullName;
                _originalUser.PhoneNumber = _form.phone;
                _originalUser.updatedOn   = DateTime.UtcNow;
                _db.UserTable.Attach(_originalUser).State = EntityState.Modified;
                await _db.SaveChangesAsync();

                return(RedirectToPage("./profile"));
            }
            return(await OnGetAsync());
        }
Exemple #3
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid)
            {
                AppUser _originalUser = await _db.UserTable.FirstOrDefaultAsync(m => m.Id == _manager.GetUserId(User));

                IdentityResult _result = await _manager.ChangePasswordAsync(_originalUser, _form.password, _form.newPassword);

                if (_result.Succeeded)
                {
                    _originalUser.updatedOn = DateTime.UtcNow;
                    _db.UserTable.Attach(_originalUser).State = EntityState.Modified;
                    await _db.SaveChangesAsync();

                    return(RedirectToPage("./profile"));
                }
                foreach (IdentityError error in _result.Errors)
                {
                    ModelState.AddModelError("_form.password", error.Description);
                }
            }
            return(Page());
        }
Exemple #4
0
 public async Task Change(AppUser _user)
 {
     _user.updatedOn = DateTime.UtcNow;
     _db.UserTable.Attach(_user).State = EntityState.Modified;
     await _db.SaveChangesAsync();
 }
Exemple #5
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (_form.acceptTerms != true)
            {
                ModelState.AddModelError("_form.acceptTerms", "Please agree to the Terms and Condition");
            }

            if (ModelState.IsValid)
            {
                AppUser _user = new AppUser
                {
                    fullName    = _form.fullName,
                    UserName    = _form.userName,
                    PhoneNumber = _form.phone,
                    Email       = _form.email,
                    createdOn   = DateTime.UtcNow,
                    updatedOn   = DateTime.UtcNow
                };

                var result = await _manager.CreateAsync(_user, _form.password);

                if (result.Succeeded)
                {
                    await _manager.AddToRoleAsync(_user, "Member");

                    await _db.SaveChangesAsync();

                    var callbackUrl = Url.Page
                                      (
                        "/App/accountConfirmed",
                        pageHandler: "Verify",
                        values: new
                    {
                        id   = _user.Id,
                        code = await _manager.GenerateEmailConfirmationTokenAsync(_user)
                    },
                        protocol: Request.Scheme
                                      );

                    var _msg = $@"
                        Dear {_form.fullName.ToUpper()},<br />
                        <br />
                        Welcome to <strong>eWallet</strong>. We have created an account for you with the username ""{_form.userName}"".<br />
                        <br />
                        To activate your account please <a href=""{HtmlEncoder.Default.Encode(callbackUrl)}"">click here.</a><br />
                        <br />
                        Or copy and paste the link below in a browser:<br />
                        <br />
                        {HtmlEncoder.Default.Encode(callbackUrl)}<br />
                        <br />
                        In case of questions or problems don't hesitate to get in touch with us at <strong>[email protected]</strong>.
                    ";
                    _mail.SendMail("*****@*****.**", _form.email, "Connekt Email Verification", _msg);

                    _msg = $@"<p>
                        Thank you for creating an account with <strong>eWallet</strong>.<br />
                        You should receive an email shortly at <strong>{_user.Email}</strong> with an activation link.<br /><br />
                        In case of questions or problems don't hesitate to get in touch with us at <strong>[email protected]</strong>.
                        </p>";

                    return(RedirectToPage("/app/emailSent", new { msg = _msg }));
                }
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }
            return(Page());
        }