コード例 #1
0
        public IHttpActionResult GetUser(string id)
        {
            ApplicationUser user    = _userService.UserManager.FindById(id);
            UserDto         userDto = new UserDto();

            AutoMapper.AutoMapUser(user, userDto);
            userDto.Role = _userService.GetUserRole(user);

            return(Ok(userDto));
        }
コード例 #2
0
        // GET: api/Account
        public IHttpActionResult LoginAndReturnUserDto(string email, string password)
        {
            var result = _userService.SignInManager.PasswordSignIn(email, password, true, shouldLockout: false);

            if (result == SignInStatus.Success)
            {
                ApplicationUser user       = _userService.UserManager.FindByEmail(email);
                UserDto         loggedUser = new UserDto();

                AutoMapper.AutoMapUser(user, loggedUser);
                loggedUser.Role = _userService.GetUserRole(user);

                return(Ok(loggedUser));
            }

            // return ResponseMessage(Request.CreateResponse(HttpStatusCode.NotFound, "LoginFailed"));

            return(Ok(new UserDto()));
        }