Esempio n. 1
0
 public UserService(ILogger logger, IMapper mapper, IAppUser userInfo, AppDbContext dbContext)
     : base(logger, mapper, userInfo, dbContext)
 {
     _userRepository           = new UserRepository(userInfo, DbContext);
     _userCredentialRepository = new UserCredentialRepository(userInfo, DbContext);
     _userRoleRepository       = new JUserRoleRepository(userInfo, DbContext);
 }
Esempio n. 2
0
        public async Task <ISingleResponse <UserModel> > AddUserAsync(UserModel details)
        {
            Logger.Info(CreateInvokedMethodLog(MethodBase.GetCurrentMethod().ReflectedType.FullName));
            var response = new SingleResponse <UserModel>();

            using (var transaction = DbContext.Database.BeginTransaction())
            {
                try
                {
                    var user = Mapper.Map <User>(details);

                    await UserRepository.AddAsync(user);

                    var userCredential = Mapper.Map <UserCredential>(details);
                    userCredential.User = user;
                    await UserCredentialRepository.AddAsync(userCredential);

                    transaction.Commit();
                    response.Model = Mapper.Map <UserModel>(user);
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    response.SetError(ex, Logger);
                }
            }

            return(response);
        }
Esempio n. 3
0
        public async Task <UserCredential> Update(UserCredential credential)
        {
            using (var uow = new UnitOfWork(Context))
            {
                var repo = new UserCredentialRepository(uow);

                return(await repo.Update(credential));
            }
        }
Esempio n. 4
0
        // This returns a user password! Do not return even the hashed and salted value from services!
        public async Task <UserCredential> GetUserCredential(int userId)
        {
            using (var uow = new UnitOfWork(Context))
            {
                var repo = new UserCredentialRepository(uow);

                return(await repo.GetAll().Where(c => c.UserId == userId).FirstOrDefaultAsync());
            }
        }
        public async Task <UserCredential> ValidatePasswordResetToken(string resetToken)
        {
            if (string.IsNullOrEmpty(resetToken))
            {
                throw new CallerException("ResetToken missing");
            }

            UserCredential userCredential;

            using (var uow = new Repositories.Auth.UnitOfWork(AuthContext))
            {
                var repo = new UserCredentialRepository(uow);

                // Index needed?
                userCredential = await repo.GetAll().Where(c => c.ResetToken == resetToken && c.ResetExpiration != null && c.ResetExpiration > DateTime.UtcNow).FirstOrDefaultAsync();
            }

            if (userCredential == null)
            {
                throw new FriendlyException("PasswordReset.TokenInvalid", "Reset token is not valid");
            }

            return(userCredential);
        }
 public LoginBusinessLogic()
 {
     _userCredentialRepository  = S360RepositoryFactory.GetRepository("USERCREDENTIAL") as UserCredentialRepository;
     _userLoginDetailRepository = S360RepositoryFactory.GetRepository("USERLOGINDETAIL") as UserLoginDetailRepository;
 }