Exemple #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));
        }
        public IResult <string> SignIn(SignInModel signInModel)
        {
            var signInModelValidator = new SignInModelValidator().Valid(signInModel);

            if (!signInModelValidator.Success)
            {
                return(signInModelValidator);
            }

            var signedInModel = UserRepository.SignIn(signInModel);

            var signedInModelValidator = new SignedInModelValidator().Valid(signedInModel);

            if (!signedInModelValidator.Success)
            {
                return(signedInModelValidator);
            }

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

            UserLogDomain.Save(userLogModel);

            var jwt = CreateJwt(signedInModel);

            return(new SuccessResult <string>(jwt));
        }
 public static UserLogEntity Create(UserLogDomain userLogDomain)
 {
     return(new UserLogEntity
            (
                userLogDomain.UserLogId,
                userLogDomain.UserId,
                userLogDomain.LogType,
                userLogDomain.DateTime
            ));
 }
        public string SignIn(SignInModel signInModel)
        {
            new SignInModelValidator().ValidateThrow(signInModel);

            TransformLoginAndPasswordToHash(signInModel);

            var signedInModel = UserRepository.SignIn(signInModel);

            new SignedInModelValidator().ValidateThrow(signedInModel);

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

            UserLogDomain.Save(userLogModel);

            return(CreateJwt(signedInModel));
        }
        public void SignOut(SignOutModel signOutModel)
        {
            var userLogModel = new UserLogModel(signOutModel.UserId, LogType.Logout);

            UserLogDomain.Save(userLogModel);
        }
Exemple #6
0
        public Task SignOutAsync(SignOutModel signOutModel)
        {
            var userLogModel = new UserLogModel(signOutModel.UserId, LogType.Logout);

            return(UserLogDomain.SaveAsync(userLogModel));
        }
Exemple #7
0
        private async Task AddUserLogAsync(long userId, LogType logType)
        {
            var userLogModel = new UserLogModel(userId, logType);

            await UserLogDomain.AddAsync(userLogModel);
        }