public Task<AuthenticationResponse> AuthenticateAsync(BaseCredentials credentials) { throw new NotImplementedException(); }
//======================================================================================================= /// <summary> /// Method used to do the actual authentication.. /// </summary> //======================================================================================================= public async Task<AuthenticationResponse> AuthenticateAsync (BaseCredentials credentials) { // When cast to this, represents Email and Password elements. The Docflock way yo. var docFlockCredentials = credentials as CustomCredentials; if (docFlockCredentials == null) throw new InvalidOperationException( "Must supply a valid set of credentials to Authenticate agsint this provider"); // Set the RestClient to use these credentials for all subsequent calls to the backend.. var httpRequest = new HttpRequest("1/Account/Login"); // Get User details for our IIdentity instance. The call fails if the credentials supplied // above were not valid. If they are valid, we pull the UserProfile back and set IIdenty.IsAuthenticated = true; var response = await this.Client.SendPostRequestAsync<CustomCredentials, DocFlockAuthenticationResponse> ((CustomCredentials)credentials, httpRequest); // Send back either a valid or empty principal to reflect the Authentication outcome.. if (response != null) { Client.Credentials = docFlockCredentials; return new AuthenticationResponse { Principal = this.CreateValidPrincipal(response) }; } else { return new AuthenticationResponse { Principal = this.CreateEmptyPrincipal() }; } }
//======================================================================================================= /// <summary> /// Method used to do the actual authentication.. /// </summary> //======================================================================================================= public async Task<AuthenticationResponse> AuthenticateAsync(BaseCredentials credentials) { // When cast to this, represents Email and Password elements. The Docflock way yo. var docFlockCredentials = credentials as CustomCredentials; if (docFlockCredentials == null) throw new InvalidOperationException( "Must supply a valid set of credentials to Authenticate agsint this provider"); return null; //while (_user == null) //{ // string message; // try // { // // Change 'MobileService' to the name of your MobileServiceClient instance. // // Sign-in using Facebook authentication. // _user = await App.MobileService.LoginAsync(MobileServiceAuthenticationProvider.Facebook); // message = // string.Format("You are now signed in - {0}", _user.UserId); // } // catch (InvalidOperationException) // { // message = "You must log in. Login Required"; // } // //var dialog = new MessageDialog(message); // //dialog.Commands.Add(new UICommand("OK")); // //await dialog.ShowAsync(); //} // Send back either a valid or empty principal to reflect the Authentication outcome.. //if (response != null) //{ // Client.Credentials = docFlockCredentials; // return new AuthenticationResponse // { // Principal = this.CreateValidPrincipal(response) // }; //} //else //{ // return new AuthenticationResponse // { // Principal = this.CreateEmptyPrincipal() // }; //} }