protected async Task <ClaimsPrincipal> Authenticate() { DetailsViewModel dvm = Model as DetailsViewModel; AuthenticationObject authObj = dvm.DetailsObject as AuthenticationObject; #if REST authObj.Validate(true); authObj.GetValidationErrors().AbortIfHasErrors(); return(await RestServices.Authenticate(App.Services, authObj.EmailProperty.Value, authObj.PasswordProperty.Value)); #endif #if WCF authObj.Validate(true); authObj.GetValidationErrors().AbortIfHasErrors(); var principal = WcfServices.Authenticate(authObj.EmailProperty.Value, authObj.PasswordProperty.Value); return(await Task.FromResult(principal)); #endif #if TWO_TIER await dvm.SaveAsync(); dvm.Errors.AbortIfHasErrors(); PersonInfo userInfo = null; using (var s = dvm.ServiceProvider.CreateScope()) { IPersonService personService = s.ServiceProvider.GetRequiredService <IPersonService>(); userInfo = (await personService.ReadAsync(authObj.EmailProperty.Value)).Result; } ClaimsIdentity ci = SecurityManager.CreateIdentity("Password", userInfo); return(new ClaimsPrincipal(ci)); #endif }
protected override void Save(object sender, EventArgs e) { DetailsViewModel dvm = Model as DetailsViewModel; AuthenticationObject authObj = dvm.DetailsObject as AuthenticationObject; try { authObj.Validate(true); authObj.GetValidationErrors().AbortIfHasErrors(); WcfServices.Authenticate(authObj.EmailProperty.Value, authObj.PasswordProperty.Value); authObj.TrackModifications = false; // to prevent confirmation on closing of the login view MainView.Start(); Close(); } catch (Exception ex) { ErrorParser ep = dvm.ServiceProvider.GetService <ErrorParser>(); ErrorList errors = ep.FromException(ex); ErrorPresenter.Show(errors); } }