Exemple #1
0
        public async Task <bool> ChangePassword(ChangePasswordCmd cmd)
        {
            var evt        = PasswordChangedEvt.MakeEventEntity(cmd);
            var insertions = await eventRepository.Create(evt);

            return(insertions > 0);
        }
Exemple #2
0
        /// <summary>
        /// Crea un usuario, hasheando la contraseña y asegurando que el email no esté ocupado
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        public async Task <UserEntity> Create(CreateUserCmd cmd)
        {
            var evt        = UserCreatedEvt.MakeEventEntity(cmd);
            var insertions = await eventRepository.Create(evt);

            if (insertions == 0)
            {
                return(null);
            }
            var user = await db.FirstAsync(u => u.CreatorEventId == evt.Id);

            var hashedPass = passwordHasher.HashPassword(user, cmd.Password);

            evt = PasswordChangedEvt.MakeEventEntity(cmd, user.Id, hashedPass);
            await eventRepository.Create(evt);

            return(user);
        }