Пример #1
0
 protected override bool CheckAccessCore(OperationContext operationContext)
 {
     try
     {
         string userName;
         string password;
         string bankName;
         var    authHeader = WebOperationContext.Current.IncomingRequest.Headers["Authorization"];
         if ((authHeader != null) && (authHeader != string.Empty))
         {
             var svcCredentials = System.Text.ASCIIEncoding.ASCII
                                  .GetString(Convert.FromBase64String(authHeader.Substring(6)))
                                  .Split(':');
             userName = svcCredentials[0];
             password = svcCredentials[1];
             bankName = svcCredentials[2];
             BusinessAccessLayer.BALLogin.BALLogin bALLogin        = new BusinessAccessLayer.BALLogin.BALLogin();
             BusinessObjects.Models.User           userInformation = bALLogin.UserCheck(userName, password, bankName);
             return(userInformation == null ? false : true);
         }
         else
         {
             WebOperationContext.Current.OutgoingResponse.Headers.Add("WWW-Authenticate: Basic realm=\"MyWCFService\"");
             throw new WebFaultException(HttpStatusCode.Unauthorized);
         }
     }
     catch (Exception ex)
     {
         ExceptionsWriter.saveEventsAndExceptions(ex, "Exceptions not handled", EventLogEntryType.Error);
         return(false);
     }
 }
Пример #2
0
 public static BusinessObjects.Models.User Login(string userName, string password, string bankName)
 {
     try
     {
         BusinessAccessLayer.BALLogin.BALLogin bALLogin = new BusinessAccessLayer.BALLogin.BALLogin();
         return(bALLogin.UserCheck(userName, password, bankName));
     }
     catch (Exception ex)
     {
         ExceptionsWriter.saveEventsAndExceptions(ex, "Exceptions not handled", EventLogEntryType.Error);
         return(null);
     }
 }
Пример #3
0
 public ActionResult login(BusinessObjects.Models.User pUser)
 {
     try
     {
         if (ModelState.IsValid)
         {
             BusinessAccessLayer.BALLogin.BALLogin bALLogin = new BusinessAccessLayer.BALLogin.BALLogin();
             pUser = bALLogin.userLogin(pUser);
             if (pUser != null)
             {
                 if (pUser.id != 0)
                 {
                     Session["UserObj"] = pUser;
                     return(RedirectToAction("Home", "Branches"));
                 }
                 else
                 {
                     ViewBag.loginMsg = GlobalResource.Resources.LangText.loginMessage;
                     return(View());
                 }
             }
             else
             {
                 return(View("Error"));
             }
         }
         else
         {
             return(View());
         }
     }
     catch (Exception ex)
     {
         ExceptionsWriter.saveExceptionToLogFile(ex);
         return(View("Error"));
     }
 }
Пример #4
0
 public ActionResult login(BusinessObjects.Models.User pUser)
 {
     try
     {
         if (ModelState.IsValid)
         {
             BusinessAccessLayer.BALLogin.BALLogin bALLogin = new BusinessAccessLayer.BALLogin.BALLogin();
             pUser = bALLogin.userLogin(pUser);
             if (pUser != null)
             {
                 if (pUser.id != 0 && owinCookieAuthorization(pUser))
                 {
                     return(RedirectToAction("Home", "Branches"));
                 }
                 else
                 {
                     ViewBag.loginMsg = GlobalResource.Resources.LangText.loginMessage;
                     return(View());
                 }
             }
             else
             {
                 return(View("Error"));
             }
         }
         else
         {
             return(View());
         }
     }
     catch (Exception ex)
     {
         ExceptionsWriter.saveEventsAndExceptions(ex, "Exceptions not handled", EventLogEntryType.Error);
         return(View("Error"));
     }
 }