Esempio n. 1
0
        public Task <IResult <string> > SignInAsync(SignInModel signInModel)
        {
            var validation = new SignInModelValidator().Valid(signInModel);

            if (!validation.Success)
            {
                return(Task.FromResult(validation));
            }

            var signedInModel = UserRepository.SignInAsync(signInModel).Result;

            validation = new SignedInModelValidator().Valid(signedInModel);
            if (!validation.Success)
            {
                return(Task.FromResult(validation));
            }

            var userLogModel = new UserLogModel(signedInModel.UserId, LogType.Login);

            UserLogDomain.SaveAsync(userLogModel);

            var jwt = CreateJwt(signedInModel);

            IResult <string> successResult = new SuccessResult <string>(jwt);

            return(Task.FromResult(successResult));
        }
Esempio n. 2
0
        public Task SignOutAsync(SignOutModel signOutModel)
        {
            var userLogModel = new UserLogModel(signOutModel.UserId, LogType.Logout);

            return(UserLogDomain.SaveAsync(userLogModel));
        }