Beispiel #1
0
        public async Task <IActionResult> Register(SmallUserVm newUser)
        {
            if (ModelState.IsValid)
            {
                // la inceput este suficient sa stiu username/email si parola,
                // nu am nevoie de data nasterii, poza sau gender

                // tempNewUserVm are doar username/email si parola,
                // dar trebuie sa trimit un User intreg in serviciu

                // datele sunt bune

                if (this.userAccountService.IsTaken(newUser.Email))
                {
                    return(View("RegisterPage", newUser));
                }
                else
                {
                    var tempUser = new Users()
                    {
                        Username     = newUser.Email,
                        Email        = newUser.Email,
                        PasswordHash = newUser.Password,
                        PhotoId      = 7 // urat tare dar nu stiu altfel, asta e poza default pt user
                    };

                    this.userAccountService.Register(tempUser);
                    await LogIn(tempUser);
                }
                return(RedirectToAction("Index", "Home"));
            }

            return(View("RegisterPage", newUser));
        }
Beispiel #2
0
        public async Task <IActionResult> Login(SmallUserVm model)
        {
            if (!ModelState.IsValid)
            {
                return(View("LoginPage", model));
            }

            var user = this.userAccountService.Login(model.Email, model.Password);

            if (user is null)
            {
                model.AreCredentialsInvalid = true;
                return(View("LoginPage", model));
            }

            await LogIn(user);

            return(RedirectToAction("Index", "Home"));
        }
Beispiel #3
0
        public IActionResult Login()
        {
            var model = new SmallUserVm();

            return(View("LoginPage", model));
        }
Beispiel #4
0
        public IActionResult Register()
        {
            var model = new SmallUserVm();

            return(View("RegisterPage", model));
        }