Exemplo n.º 1
0
		public async Task RegisterAsync(Attendee attendee)
		{
			var data = AppFactory.Mapper.Value.Map<Data.Entity.Table.Attendee>(attendee);

			var token = new QuickAuthToken
			{
				Email = attendee.EMail,
				Token = Guid.NewGuid().ToString("N")
			};

			var email = new ConfirmRegistrationMessage
			{
				Email = attendee.EMail,
				FullName = attendee.FullName,
				Token = token.Token
			};

			await Task.WhenAll(
				DataFactory.AttendeeService.Value.InsertAsync(data),
				AppFactory.QuickAuthTokenService.Value.AddQuickAuthTokenAsync(token),
				NotificationFactory.AttendeeNotificationService.Value.SendRegistrationConfirmationEmailAsync(email)
			);
		}
Exemplo n.º 2
0
		public async Task UpdateProfileAsync(Attendee attendee)
		{
			var data = AppFactory.Mapper.Value.Map<Data.Entity.Table.Attendee>(attendee);
			data.ETag = "*";

			await DataFactory.AttendeeService.Value.ReplaceAsync(data);
		}
Exemplo n.º 3
0
		public bool IsPasswordValid(Attendee attendee, string plainPassword)
		{
			var hashedPassword = Hash(plainPassword, attendee.Salt);
			return SlowEquals(attendee.PasswordHash, hashedPassword);
		}
Exemplo n.º 4
0
		public async Task<ActionResult> Registration(RegistrationModel model)
		{
			var attendeeExisted = await AppFactory.AttendeeService.Value.GetAttendeeByEmailAsync(model.Email);
			if (attendeeExisted != null)
			{
				model.ErrorMessage = "Пользователь с таким адресом электронной почты уже есть в системе. Если вы забыли пароль, то воспользуйтесь функцией восстановления пароля на странице входа в личный кабинет.";

				model.Password = string.Empty;
				return View(model);
			}

			var salt = AppFactory.AttendeeService.Value.GenerateSalt();
			var passwordHash = AppFactory.AttendeeService.Value.Hash(model.Password, salt);

			var attendee = new Attendee
			{
				EMail = model.Email,
				FirstName = model.FirstName,
				LastName = model.LastName,
				Company = model.Company,
				Salt = salt,
				PasswordHash = passwordHash
			};
			
			await AppFactory.AttendeeService.Value.RegisterAsync(attendee);

			return RedirectToAction("ConfirmRegistration");
		}