public bool loginAndSetAccessLevel(string sUserName, string sPassword) { if (isBlank(sUserName) || isBlank(sPassword)) { accessLevel = HI_ACCESS_LEVEL.NOT_LOGGED_IN; return false; } bool bLoggedIn = false; GLOBAL_SQL_CONN conn = new GLOBAL_SQL_CONN(this); try { string sEncrypted = Dinfordel.Utils.CryptUtils.EncryptPassword(sUserName, sPassword); string sSql = "select a.shop_id from administrator a where a.email='" + sUserName + "' and a.password='******' "; // b) Aministratorlogin. Få tak i shop_id med sMerchantId ... GLOBAL_SQL_COMMAND command = new GLOBAL_SQL_COMMAND(sSql, conn); GLOBAL_SQL_READER reader = new GLOBAL_SQL_READER(command); if (reader.Read()) { sAdminChain = reader.c("shop_id").ToString(); bLoggedIn = true; // Get shop level ... } } catch (Exception e) { bLoggedIn = false; } finally { conn.Close(); } if (!bLoggedIn) { accessLevel = HI_ACCESS_LEVEL.NOT_LOGGED_IN; } // Top ? ShopParentChild shopParentChild = getShopParentChildFrom(this, sAdminChain); if (shopParentChild.bOnTop) { accessLevel = HI_ACCESS_LEVEL.LOGGED_IN_AS_SUPERUSER; bOriginalSuperUser = true; setCurrentChain(sAdminChain); return true; } // Chain ? shopParentChild = getShopParentChildFrom(this, shopParentChild.sParentId); if (shopParentChild.bOnTop) { accessLevel = HI_ACCESS_LEVEL.LOGGED_IN_AS_CHAIN; sCurrentChainId = sAdminChain; setChainEntity(); return true; } // Shop ? shopParentChild = getShopParentChildFrom(this, shopParentChild.sParentId); if (shopParentChild.bOnTop) { accessLevel = HI_ACCESS_LEVEL.LOGGED_IN_AS_SHOP; return true; } return false; }
public void setAccessLevel(HI_ACCESS_LEVEL _accessLevel) { accessLevel = _accessLevel; }