public HttpResponseMessage Login() { var authenticationToken = Request.Headers.Authorization.Parameter; var decodedAuthenticationToken = Encoding.UTF8.GetString(Convert.FromBase64String(authenticationToken)); var usernamePasswordArray = decodedAuthenticationToken.Split(':'); var userName = usernamePasswordArray[0]; var password = usernamePasswordArray[1]; var IP = Request.Headers.GetValues("IP").First(); Login login = new Login() { UserName = userName, Password = password }; Users LoginUser = UBL.Login(login); if (LoginUser.UserID > 0) { GeolocationStack location = GetGeolocation(IP); LoginRecord loginRecord = new LoginRecord() { UserID = LoginUser.UserID, IP = location.Ip, Country = location.CountryName, Region = location.RegionName, City = location.City }; UBL.AddLogin(loginRecord); Users Details = UBL.Details(LoginUser.UserID); //Details.RolesData = RBL.List().Where(x => x.RoleID == Details.RoleID).FirstOrDefault(); //Details.GroupList = GBL.ListbyUser(Details.UserID); var token = GenerateToken(LoginUser.UserID); if (token.TokenID.Length > 0) { Details.NeedResetPwd = LoginUser.NeedResetPwd; Details.Token = token.TokenID; Details.TokenExpires = token.ExpiresDate; Details.TokenExpiresMin = expireTime; return(this.Request.CreateResponse(HttpStatusCode.OK, Details)); } else { return(this.Request.CreateResponse(HttpStatusCode.InternalServerError)); } } else { return(this.Request.CreateResponse(HttpStatusCode.Unauthorized)); } }