private bool IsValid(Credentials model) { //ändra false till true om vi vill ha en permanent cookie //ska bara posta stupid CredentialsRecived cr = new CredentialsRecived(); cr.Id = 0; cr.username = model.username; cr.password = model.password; cr.permission = "bookingadmin"; return(CheckLogin(cr).Result); }
// GET: Login public async Task <bool> CheckLogin([Bind(Include = "Id,username,password,permission")] CredentialsRecived creds) { if (ModelState.IsValid) { using (var client = new HttpClient()) { client.BaseAddress = new Uri(baseUrl); var response = client.PostAsJsonAsync("api/bookinglogin/", creds).Result; if (response.IsSuccessStatusCode) { return(true); } else { ModelState.AddModelError(string.Empty, "Server error try after some time."); } } } return(false); }