예제 #1
0
        public async Task <bool> Login([FromBody] LoginModel model)
        {
            var result = await safeAccountService.Login(model);

            if (!string.IsNullOrEmpty(result))
            {
                HttpContext.AddAuthorizationHeader(result);
                return(true);
            }
            else
            {
                HttpContext.Response.StatusCode = 401;
                return(false);
            }
        }
        public async Task <string> Login(LoginModel model)
        {
            var token = await safeAccountService.Login(model);

            if (token == null)
            {
                return(null);
            }

            var user = await safeAccountService.GetUserByName(model.Username);

            OnNext(new SignInLogModel
            {
                UserName   = user.Login,
                isEmployee = user.isEmployee,
                FullName   = user.Name,
                DateTime   = DateTime.Now
            });

            return(token);
        }