using AIAHTML5.Server.Models; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Http; using System.Web.Http; namespace AIAHTML5.Server.Controllers { public class AuthenticateController : ApiController { // GET: api/Users/5 public HttpResponseMessage Get(string applicationName, string username, string password) { try { dynamic user = AppUser.Authenticate(applicationName, username, password); if (user != null) return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(user)) }; else return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(new AppResponse(false, "Invalid Username or Password!"))) }; } catch (Exception ex) { return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(new AppResponse(false, "Authentication Failure. Please contact Customer Support!"))) }; } } } }