public async Task <IDataResult <TokenModel> > SignInAsync(SignInModel signInModel) { var validation = new SignInModelValidator().Validate(signInModel); if (validation.IsError) { return(DataResult <TokenModel> .Error(validation.Message)); } var signedInModel = await UserRepository.SignInAsync(signInModel); validation = SignInService.Validate(signedInModel, signInModel); if (validation.IsError) { return(DataResult <TokenModel> .Error(validation.Message)); } var userLogModel = new UserLogModel(signedInModel.Id, LogType.SignIn); await UserLogApplicationService.AddAsync(userLogModel); await UnitOfWork.SaveChangesAsync(); var tokenModel = SignInService.CreateToken(signedInModel); return(DataResult <TokenModel> .Success(tokenModel)); }
public async Task <IDataResult <TokenModel> > SignInAsync(SignInModel signInModel) { var validation = new SignInModelValidator().Valid(signInModel); if (!validation.Success) { return(new ErrorDataResult <TokenModel>(validation.Message)); } UserDomainService.GenerateHash(signInModel); var signedInModel = await UserRepository.SignInAsync(signInModel); validation = new SignedInModelValidator().Valid(signedInModel); if (!validation.Success) { return(new ErrorDataResult <TokenModel>(validation.Message)); } var addUserLogModel = new AddUserLogModel(signedInModel.UserId, LogType.SignIn); await UserLogApplicationService.AddAsync(addUserLogModel); var tokenModel = UserDomainService.GenerateToken(signedInModel); return(new SuccessDataResult <TokenModel>(tokenModel)); }
public async Task <IDataResult <TokenModel> > SignInAsync(SignInModel signInModel) { var validation = new SignInModelValidator().Valid(signInModel); if (!validation.Success) { return(new ErrorDataResult <TokenModel>(validation.Message)); } var signedInModel = await UserRepository.SignInAsync(signInModel); if (!SignInService.Validate(signedInModel, signInModel)) { return(new ErrorDataResult <TokenModel>(Texts.LoginPasswordInvalid)); } var tokenModel = SignInService.CreateToken(signedInModel); var addUserLogModel = new AddUserLogModel(signedInModel.UserId, LogType.SignIn); await UserLogApplicationService.AddAsync(addUserLogModel); await UnitOfWork.SaveChangesAsync(); return(new SuccessDataResult <TokenModel>(tokenModel)); }
public async Task SignOutAsync(SignOutModel signOutModel) { var userLogModel = new UserLogModel(signOutModel.Id, LogType.SignOut); await UserLogApplicationService.AddAsync(userLogModel); await UnitOfWork.SaveChangesAsync(); }
public async Task SignOutAsync(SignOutModel signOutModel) { var addUserLogModel = new AddUserLogModel(signOutModel.UserId, LogType.SignOut); await UserLogApplicationService.AddAsync(addUserLogModel); }
private async Task AddUserLogAsync(long userId, LogType logType) { var addUserLogModel = new AddUserLogModel(userId, logType); await UserLogApplicationService.AddAsync(addUserLogModel); }