Esempio n. 1
0
        //step 12 checking for valid link.
        public IActionResult VerifyEmail(string token)
        {
            @ViewData["token"] = token;
            DboEmailVerification dbEmv = _context.DboEmailVerification.SingleOrDefault(m => m.Vchr250Token == token && m.BEnabled == true);

            if (dbEmv != null)
            {
                return(View());
            }
            else
            {
                //Access denied page
                return(RedirectToAction(nameof(AccountController.AccessDenied), "Account", new { debug = "" }));
            }
        }
Esempio n. 2
0
        public IActionResult VerifyEmail(RegisterviewModel model, string token)
        {
            DboEmailVerification dbEmv = _context.DboEmailVerification.SingleOrDefault(m => m.Vchr250Token == token && m.BEnabled == true);

            if (dbEmv != null)
            {
                string username   = model.UserName;
                byte[] password   = System.Text.Encoding.Unicode.GetBytes(model.Password);
                string domainName = Utility.GetUserNameFromEmail(dbEmv.Nvch128Email, true);
                TempData["UserName"] = username;
                LoginViewModel mode1 = new LoginViewModel {
                    Email = dbEmv.Nvch128Email
                };

                DboCredentialOrganizationInfo user = _context.DboCredentialOrganizationInfo.SingleOrDefault(m => m.Vchr128EMailDomain == domainName && m.BAllowEmailAssociation == true && m.BAllowSelfRegistration == true);
                //validate whether user record exists
                DboCredential dbCr = _context.DboCredential.SingleOrDefault(m => m.Vchr32Name == model.UserName && m.Bin64PasswordHash == password && m.BEnabled == false);
                if (dbCr != null)
                {
                    //step 6 creating user records.
                    new BusinessLayer(_context).CreateNormalUserCredential(username, user.BintCredentialId);
                    TempData["UserName"] = username;
                    SetSessionUserName(username);
                    dbEmv.BEnabled = false;
                    _context.DboEmailVerification.Update(dbEmv);
                    _context.SaveChanges();
                    return(RedirectToAction(nameof(CredentialsController.ManageCredentials), "Credentials", new { debug = "" }));
                }
                else
                {
                    ViewData["ErroMessage"] = "User doenst not exists";
                    return(View());
                }
            }
            else
            {
                //step 10 Access Denied.
                return(RedirectToAction(nameof(AccountController.AccessDenied), "Account", new { debug = "" }));
            }
        }