Exemple #1
0
        public async Task <ActionResult <LoginResponseModel> > Login(LoginRequestModel model)
        {
            var user = await this.userManager.FindByNameAsync(model.UserName);

            if (user == null)
            {
                return(Unauthorized());
            }

            var passwordValid = await this.userManager.CheckPasswordAsync(user, model.Password);

            if (!passwordValid)
            {
                return(Unauthorized());
            }

            var token = this.identity.GenerateJwtToken(
                user.Id,
                user.UserName,
                this.appSettings.Secret);

            var userDetails = new UserDetailsServiceModel
            {
                UserName = user.UserName,
                Email    = user.Email,
                Id       = user.Id
            };

            return(new LoginResponseModel
            {
                Token = token,
                User = userDetails
            });
        }
Exemple #2
0
        public IActionResult ApplicationDetails(int id)
        {
            UserDetailsServiceModel model =
                this.userService.ApplicationDetails(id);

            return(View(model));
        }
Exemple #3
0
        public async Task <IActionResult> UpdateUserOrderInfo(UserDetailsServiceModel model)
        {
            var userId = this.userManager.GetUserId(User);

            await this.users.UpdateOrderInfoAsync(userId, model.Address, model.City, model.PhoneNumber);

            return(RedirectToAction(nameof(ShoppingCartController.Items), new { area = "", controller = "ShoppingCart" }));
        }
Exemple #4
0
        public IActionResult Profile(string username)
        {
            if (username == null)
            {
                return(NotFound());
            }

            UserDetailsServiceModel model = this.userService.GetUserDetailsByUsername(username);

            if (model == null)
            {
                return(NotFound());
            }

            return(this.View(model));
        }