Пример #1
0
		public BaseUser(BaseRegisterViewModel model) : base(model.UserName)
		{
			if (model != null)
			{

				if (model is IdentifyingRegisterViewModel)
				{
					Email = (model as IdentifyingRegisterViewModel).Email;
				}

				if (model.Password != model.ConfirmPassword)
				{
					throw new ArgumentException("Supplied Passwords are not the same");
				}

			}
			else
			{
				throw new ArgumentNullException(nameof(model));
			}
		}
Пример #2
0
		//todo: fix
		public async Task<bool> Register(BaseRegisterViewModel registrationInfo)
		{
			if (registrationInfo != null)
			{
				using (HttpResponseMessage response = await this._client.PostAsync(this.RegisterRoute,
													new JsonContent(JsonConvert.SerializeObject(registrationInfo))))
				{
					if (response.IsSuccessStatusCode)
					{
						//Grab the cookies
						var cookies = response.Headers.GetValues("Set-Cookie"); //First(x => x.StartsWith(".AspNetCore.Microsoft.Identity.Application"));

						var processedCookie = ProcessCookies(CleanCookies(cookies));

						this.AuthToken = processedCookie;

						return true;
					}
					else
					{
						return false;
					}
				}
			}
			else
			{
				throw new ArgumentNullException(nameof(registrationInfo));
			}
		}