Esempio n. 1
0
        public async Task <ActionResult> ForgetPass(string Email)
        {
            Login login = await auth.GetUser(Email);

            if (login != null)
            {
                Random generator = new Random();
                string password  = generator.Next(0, 999999).ToString("D6");
                await sender.SendEmailAsync(Email, "change password", "Please use this code <b>" + password + "</b> for login ");

                login.sentdate = DateTime.Now.ToShortDateString();

                login.Email      = Email;
                login.RandomPass = password;
                string id = Convert.ToString(login.Id);
                log.Update(login, id);
                await uow.Commit();
            }
            return(RedirectToAction("Login"));
        }
Esempio n. 2
0
        public async Task <ActionResult <Admins> > Edit(string id, Admins value)
        {
            // var product = new Product(value.Id);
            value.Id = ObjectId.Parse(id);
            Admins admin = await _Admins.GetById(id);

            _Admins.Update(value, id);
            Login Login = new Login();

            Login = await Auth.GetUser(admin.Email);

            if (admin.Email != value.Email)
            {
                Random generator = new Random();
                string password  = generator.Next(0, 999999).ToString("D6");
                await sender.SendEmailAsync(value.Email, "Your account is successfully created", "Please use this code <b>" + password + "</b> for login ");

                Login.Email        = value.Email;
                Login.RandomPass   = password;
                Login.Role         = value.Role;
                Login.PasswordHash = null;
                Login.PasswordSalt = null;
                Login.sentdate     = DateTime.Now.ToShortDateString();
            }
            else
            {
                Login.Role = value.Role;
            }

            _login.Update(Login, Convert.ToString(Login.Id));


            await _uow.Commit();

            return(RedirectToAction("Index"));
        }