Beispiel #1
0
        //Create new login for debtor
        private async Task CreateLogin(Debtor debtor)
        {
            try {
                User user = new User();
                user.Debtor   = debtor;
                user.Email    = debtor.Email;
                user.Password = debtor.FirstName + "_" + DateTime.Now.ToString("ddMMHH");

                //Encrypt password
                string hash = encryption.Encrypt(user.Password);
                user.Password = hash;

                _context.Users.Add(user);
                await _context.SaveChangesAsync();

                //Send email with username and password
                AuthMessageSender email = new AuthMessageSender(_settings);
                await email.SendLoginEmailAsync(user.Email, encryption.Decrypt(user.Password));
            } catch (Exception ex) {
                Debug.WriteLine(ex);
            }
        }