Пример #1
0
        public string AuthenticateUser(string Username, string Password)
        {
            string strResult = string.Empty;

            try
            {
                LoginStatusBL objBL = new LoginStatusBL();

                // code for check login method
                UserInfo userInfo = objBL.DoLoginInfo(Username, Password);

                if (userInfo != null)
                {
                    TokenBL objToken = new TokenBL();
                    string  token    = objToken.SetUserToken(userInfo);
                    //Response.Headers.Add("token", token);
                    return(token);
                }
                else
                {
                    throw new Exception("Unable to Authorize.");
                }
            }
            catch (WebException ex)
            {
                strResult = new StreamReader(ex.Response.GetResponseStream()).ReadToEnd();
            }
            catch (Exception ex)
            {
                strResult = ex.Message;
            }
            return(strResult);
        }
Пример #2
0
 public string GetTokenDescriptions(string key, string uId)
 {
     try
     {
         LoginStatusBL loginStatus = new LoginStatusBL();
         UserInfo      user        = loginStatus.ValidateToken(key);
         if (user != null)
         {
             return("Token not is called for uid " + uId);
         }
         else
         {
             throw new Exception("UnAutorize person to acess");
         }
     }
     catch (Exception ex)
     {
         // throw new WebFaultException<string>(ex.Message.ToString(), HttpStatusCode.Unauthorized);
     }
     return(string.Empty);
 }