示例#1
0
        public ActionResult <RE <LoginResponse> > Login(LoginRequest request)
        {
            var response = new RE <LoginResponse>();

            try
            {
                var user = _userService.Authenticate(request);

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


                var r = new LoginResponse();

                r.credidentals = new Credidentals()
                {
                    access_token = user.authToken, token_type = "Bearer"
                };

                //automap
                r.user = new Models.LoginUser()
                {
                    id = user.id.ToString(), userName = user.username
                };

                response.data = r;
                response.code = Ok().StatusCode;
            }
            catch (Error ex)
            {
                var re = response.Exception(ex);



                return(BadRequest());
            }
            catch (Exception ex)
            {
                return(response.Exception(ex));
            }


            return(response);
        }