Beispiel #1
0
        public async Task <bool> SaveUser(UserViewModel model)
        {
            var dto  = model.BuildDto();
            var user = await _userDataSerice.Get(dto.Username);

            string tmpPassword = null;
            string hash        = null;
            string salt        = null;
            var    createFlow  = false;

            if (user == null)
            {
                createFlow  = true;
                tmpPassword = Guid.NewGuid().ToString("N").Substring(20);
                salt        = GetSalt();
                hash        = GetHash(tmpPassword, salt);
            }

            var created = await _userDataSerice.Save(dto, hash, salt);

            if (createFlow && created)
            {
                await _emailService.NewUser(dto.Username, dto.Email, tmpPassword);
            }

            return(created);
        }