Beispiel #1
0
 // POST api/<controller>
 public HttpResponseMessage Post(AuthenticationFM credentials)
 {
     HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.Forbidden);
     var result = authService.Authenticate(credentials);
     if (result != null)
     {
         helper.SetKey(Request, Response, result.Key);
         response.StatusCode = HttpStatusCode.OK;
     }
     return response;
 }
 public AuthenticationVM Authenticate(AuthenticationFM credentials)
 {
     AuthenticationVM vm = null;
     if (credentials.Key != null)
     {
         vm = AuthByKey(credentials.Key);
     }
     else if (credentials.Email != null && credentials.Password != null)
     {
         vm = AuthByLogin(credentials.Email, credentials.Password);
     }
     return vm;
 }