private void ActivateUser(UserInfo user, string newPwd)
 {
     try
     {
         //Set status to activated
         user.ActivationStatus = EmployeeActivationStatus.Activated;
         SecurityContext.AuthenticateMe(ASC.Core.Configuration.Constants.CoreSystem);
         CoreContext.UserManager.SaveUserInfo(user);
         if (!string.IsNullOrEmpty(newPwd))
         {
             //set password if it's specified
             SecurityContext.SetUserPassword(user.ID, newPwd);
         }
     }
     catch (Exception ex)
     {
         ShowError(ex.Message);
     }
     finally
     {
         SecurityContext.Logout(); //Logout from core system
     }
     //Login user
     try
     {
         var cookiesKey = SecurityContext.AuthenticateMe(user.ID);
         CookiesManager.SetCookies(CookiesType.UserID, user.ID.ToString());
         CookiesManager.SetCookies(CookiesType.AuthKey, cookiesKey);
     }
     catch (Exception exception)
     {
         ShowError(exception.Message);
         return;
     }
 }
        private void UserAuth(UserInfo user)
        {
            if (SecurityContext.IsAuthenticated)
            {
                return;
            }

            if (StudioSmsNotificationSettings.IsVisibleSettings && StudioSmsNotificationSettings.Enable)
            {
                Session["refererURL"] = Request.GetUrlRewriter().AbsoluteUri;
                Response.Redirect(Confirm.SmsConfirmUrl(user), true);
                return;
            }
            if (TfaAppAuthSettings.IsVisibleSettings && TfaAppAuthSettings.Enable)
            {
                Session["refererURL"] = Request.GetUrlRewriter().AbsoluteUri;
                Response.Redirect(Confirm.TfaConfirmUrl(user), true);
                return;
            }

            var cookiesKey = SecurityContext.AuthenticateMe(user.ID);

            CookiesManager.SetCookies(CookiesType.AuthKey, cookiesKey);
            MessageService.Send(Request, MessageAction.LoginSuccess);
        }
Example #3
0
        public override void OK()
        {
            if (_isOKProcessing)
            {
                return;
            }
            _isOKProcessing = true;
            SettingSaver.Save(Controls);
            Settings.LoadSettings();

            Core.ResourceAP.RunJob(new UpdateDefaultsDelegate(UpdateDefaults),
                                   _oldUpdateFrequency, _oldUpdatePeriod);
            if (_chkShowDesktopAlert.Checked != _wasDesktopAlertChecked)
            {
                if (_chkShowDesktopAlert.Checked)
                {
                    Core.ResourceAP.RunJob(new MethodInvoker(CreateDesktopAlertRule));
                }
                else
                {
                    Core.ResourceAP.RunJob(new MethodInvoker(DeleteDesktopAlertRule));
                }
            }
            CookiesManager.SetUserCookieProviderName(typeof(RSSUnitOfWork), _cookieProviderSelector.SelectedProfileName);
            _isOKProcessing = false;

            WriteFontCharacteristics();
            WriteItemFormattingOptions();

            Core.SettingStore.WriteBool("NewspaperView()", "AllowHoverSelection", _checkNewspaperAllowHoverSelection.Checked);
            Core.SettingStore.WriteBool(IniKeys.Section, IniKeys.PropagateFavIconToItems, _checkPropagateFavIconToItems.Checked);
        }
Example #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         ResetSession(); CookiesManager.ResetCookie();
     }
 }
Example #5
0
        protected override void OnPreInit(EventArgs e)
        {
            base.OnPreInit(e);

            if (!SecurityContext.IsAuthenticated)
            {
                if (CoreContext.Configuration.Personal)
                {
                    if (CoreContext.Configuration.Standalone)
                    {
                        var admin  = CoreContext.UserManager.GetUserByUserName("administrator");
                        var cookie = SecurityContext.AuthenticateMe(admin.ID);
                        CookiesManager.SetCookies(CookiesType.AuthKey, cookie);
                        Response.Redirect(CommonLinkUtility.GetDefault(), true);
                    }

                    if (Request["campaign"] == "personal")
                    {
                        Session["campaign"] = "personal";
                    }
                    CheckSocialMedia();

                    SetLanguage(abTesting: true);
                }

                var token = Request["asc_auth_key"];
                if (SecurityContext.AuthenticateMe(token))
                {
                    CookiesManager.SetCookies(CookiesType.AuthKey, token);

                    var refererURL = Request["refererURL"];
                    if (string.IsNullOrEmpty(refererURL))
                    {
                        refererURL = "~/auth.aspx";
                    }

                    Response.Redirect(refererURL, true);
                }

                return;
            }

            if (IsLogout)
            {
                var loginName = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID).DisplayUserName(false);
                ProcessLogout();
                MessageService.Send(HttpContext.Current.Request, loginName, MessageAction.Logout);

                // slo redirect
                if (SsoImporter.SloIsEnable && HttpContext.Current != null)
                {
                    HttpContext.Current.Response.Redirect(SsoImporter.SloEndPoint, true);
                }
                Response.Redirect("~/auth.aspx", true);
            }
            else
            {
                Response.Redirect(CommonLinkUtility.GetDefault(), true);
            }
        }
Example #6
0
        private void ProcessEmailActivation(string email)
        {
            var user = CoreContext.UserManager.GetUserByEmail(email);

            if (user.ID.Equals(Constants.LostUser.ID))
            {
                ShowError(Resource.ErrorConfirmURLError);
            }
            else if (user.ActivationStatus == EmployeeActivationStatus.Activated)
            {
                Response.Redirect("~/");
            }
            else
            {
                try
                {
                    SecurityContext.AuthenticateMe(ASC.Core.Configuration.Constants.CoreSystem);
                    user.ActivationStatus = EmployeeActivationStatus.Activated;
                    CoreContext.UserManager.SaveUserInfo(user);
                }
                finally
                {
                    SecurityContext.Logout();
                    CookiesManager.ClearCookies(CookiesType.AuthKey);
                }

                var redirectUrl = String.Format("~/auth.aspx?confirmed-email={0}", email);
                Response.Redirect(redirectUrl, true);
            }
        }
Example #7
0
 public bool Authorize(HttpContextBase context)
 {
     if (!SecurityContext.IsAuthenticated)
     {
         try
         {
             var cookie = CookiesManager.GetRequestVar(CookiesType.AuthKey).If(x => string.IsNullOrEmpty(x), () => context.Request.Headers["Authorization"]);
             if (string.IsNullOrEmpty(cookie))
             {
             }
             if (cookie != null && !string.IsNullOrEmpty(cookie))
             {
                 if (!SecurityContext.AuthenticateMe(cookie))
                 {
                     _log.Warn("ASC cookie auth failed with cookie={0}", cookie);
                 }
                 return(Core.SecurityContext.IsAuthenticated);
             }
             _log.Debug("no ASC cookie");
         }
         catch (Exception e)
         {
             _log.Error(e, "ASC cookie auth error");
         }
     }
     return(Core.SecurityContext.IsAuthenticated);
 }
Example #8
0
        public async Task <User> ChangePhoto(IFormFile Photo)
        {
            Account Account = await db
                              .Accounts
                              .SingleOrDefaultAsync(x =>
                                                    x.AccountId == CookiesManager.GetIdByGuid(new Guid(Request.Cookies["AccountId"])));

            if (Account != null)
            {
                if (Photo != null)
                {
                    var path = Path.Combine(
                        Directory.GetCurrentDirectory(), "storage",
                        Account.AccountId.ToString());

                    using (FileStream fs = new FileStream(path, FileMode.Create))
                    {
                        await Photo.CopyToAsync(fs);

                        Account.HasPhoto = true;

                        await db.SaveChangesAsync();
                    }

                    return(new User(Account));
                }

                return(null);
            }

            return(null);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //声名一个数据集合
            var listString = new List <string>()
            {
                "a", "b", "c"
            };
            //缓存key
            string key = "cokey";

            //获取实例
            var cookiesManager = CookiesManager <List <string> > .GetInstance();

            //插入缓存
            cookiesManager.Add(key, listString, cookiesManager.Minutes * 30);//过期30分钟
            //add有其它重载 上面是最基本的

            //获取
            List <string> cookiesList = cookiesManager[key];

            //其它方法
            cookiesManager.ContainsKey(key);

            cookiesManager.Remove(key);                          //删除

            cookiesManager.RemoveAll(c => c.Contains("sales_")); //删除key包含sales_的cookies

            cookiesManager.GetAllKey();                          //获取所有key
        }
Example #10
0
        public int GetLoginEventIdFromCookie()
        {
            var cookie       = CookiesManager.GetCookies(CookiesType.AuthKey);
            int loginEventId = CookieStorage.GetLoginEventIdFromCookie(cookie);

            return(loginEventId);
        }
Example #11
0
        public async Task <Account> Login([FromBody] Account Account)
        {
            Account.Password = GenerateSHA512String(Account.Password);

            Account LoginedAccount = await db
                                     .Accounts
                                     .SingleOrDefaultAsync(x => x.Login == Account.Login && x.Password == Account.Password);

            if (LoginedAccount != null)
            {
                Response
                .Cookies
                .Append("AccountId",
                        CookiesManager
                        .Push(LoginedAccount
                              .AccountId)
                        .ToString(),
                        new CookieOptions
                {
                    Expires = DateTime.Now.AddDays(10)
                });

                return(Account);
            }

            return(null);
        }
Example #12
0
 /// <summary>
 /// 验证用户信息并把用户信息和学校信息记录到Session
 /// </summary>
 /// <param name="user"></param>
 /// <param name="schoolId"></param>
 /// <returns></returns>
 private bool loginHandle(UserInfo user, string schoolId)
 {
     this.UserSchoolInfo = new TcpClient_BespeakSeat.TcpClient_Login().GetSingleSchoolInfo(schoolId);
     this.BespeakHandler = new TcpClient_BespeakSeat.TcpClient_BespeakSeatAllMethod(this.UserSchoolInfo);
     AMS.Model.AMS_School school = this.UserSchoolInfo;
     if (school == null)
     {
         spanWarmInfo.Visible   = true;
         spanWarmInfo.InnerText = string.Format("获取学校信息失败。");
         Session.Clear();
         CookiesManager.RemoveCookies("userInfo");
         return(false);
     }
     try
     {
         this.LoginUserInfo = BespeakHandler.CheckAndGetReaderInfo(user, school);
         return(true);
     }
     catch (RemoteServiceLinkFailed ex)
     {
         spanWarmInfo.Visible   = true;
         spanWarmInfo.InnerText = string.Format("连接学校服务器失败,可能是学校已经关闭了服务器的远程访问。");
         Session.Clear();
         CookiesManager.RemoveCookies("userInfo");
         return(false);
     }
     catch (Exception ex)
     {
         spanWarmInfo.Visible   = true;
         spanWarmInfo.InnerText = string.Format("登录失败!");
         Session.Clear();
         CookiesManager.RemoveCookies("userInfo");
         return(false);
     }
 }
        public void Remove(object sender, EventArgs e)
        {
            IUnityContainer container      = (IUnityContainer)HttpContext.Current.Application["unityContainer"];
            ICommentService commentService = container.Resolve <ICommentService>();

            UserSession userSession = (UserSession)this.Context.Session["userSession"];
            long        userId      = userSession.UserProfileId;

            try
            {
                commentService.RemoveComment(userId, CommentId);
            }
            catch (UserNotAuthorizedException <CommentDetails> )
            {
                pError.Visible = true;
            }

            if (CookiesManager.GetPreferredSearchEngine(Context) == "webshop")
            {
                Response.Redirect(Response.ApplyAppPathModifier("~/Pages/Movie/Movie.aspx?movieId=" + MovieId));
            }
            else
            {
                Response.Redirect(Response.ApplyAppPathModifier("~/Pages/Movie/MovieXml.aspx?movieId=" + MovieId));
            }
        }
Example #14
0
 /// <summary>
 /// 验证用户信息并把用户信息和学校信息记录到Session
 /// </summary>
 /// <param name="user"></param>
 /// <param name="schoolId"></param>
 /// <returns></returns>
 private bool loginHandle(UserInfo user)
 {
     //this.UserSchoolInfo = handler.GetSingleSchoolInfo(schoolId);
     AMS.Model.AMS_School school = new AMS.Model.AMS_School();
     school.ConnectionString = ConfigurationManager.ConnectionStrings["ConnStr"].ToString();
     this.UserSchoolInfo     = school;
     //ConfigurationSettings.AppSettings["ConnStr"];
     if (string.IsNullOrEmpty(this.UserSchoolInfo.ConnectionString))
     {
         return(false);
     }
     try
     {
         this.LoginUserInfo = handler.CheckAndGetReaderInfo(user, this.UserSchoolInfo);
         return(true);
     }
     catch (RemoteServiceLinkFailed ex)
     {
         Session.Clear();
         CookiesManager.RemoveCookies("userInfo");
         return(false);
     }
     catch (Exception ex)
     {
         Session.Clear();
         CookiesManager.RemoveCookies("userInfo");
         return(false);
     }
 }
        private static String GetModuleResource(String resourceClassTypeName, String resourseKey)
        {
            if (string.IsNullOrEmpty(resourseKey))
            {
                return(string.Empty);
            }
            try
            {
                var type = Type.GetType(resourceClassTypeName);

                var resManager =
                    (ResourceManager)type.InvokeMember(
                        "resourceMan",
                        BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetField | BindingFlags.Public, null, type, null);

                //custom
                if (!SecurityContext.IsAuthenticated)
                {
                    SecurityContext.AuthenticateMe(CookiesManager.GetCookies(CookiesType.AuthKey));
                }
                var u       = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);
                var culture = !string.IsNullOrEmpty(u.CultureName)
                                  ? CultureInfo.GetCultureInfo(u.CultureName)
                                  : CoreContext.TenantManager.GetCurrentTenant().GetCulture();
                return(resManager.GetString(resourseKey, culture));
            }
            catch (Exception)
            {
                return(String.Empty);
            }
        }
Example #16
0
        public override void OK()
        {
            ISettingStore   settings   = Core.SettingStore;
            int             lastMethod = BookmarkService.DownloadMethod;
            BookmarkService service    = FavoritesPlugin._bookmarkService;

            if (_idleButton.Checked)
            {
                BookmarkService.DownloadMethod = 0;
                if (lastMethod != 0)
                {
                    service.SynchronizeBookmarks();
                }
            }
            else if (_immediateButton.Checked)
            {
                BookmarkService.DownloadMethod = 1;
                if (lastMethod != 1)
                {
                    service.SynchronizeBookmarks();
                }
            }
            else
            {
                BookmarkService.DownloadMethod = 2;
            }
            CookiesManager.SetUserCookieProviderName(typeof(FavoriteJob), _cookieProviderSelector.SelectedProfileName);
            IResource res = (IResource)_bookmarkFoldersBox.SelectedItem;

            if (res != null)
            {
                settings.WriteInt("Favorites", "CatAnnRoot", res.Id);
            }
        }
Example #17
0
        public void Populate(Type userClass)
        {
            string providerName = CookiesManager.GetUserCookieProviderName(userClass);

            _cookieProvidersBox.SuspendLayout();
            _cookieProvidersBox.Items.Clear();
            CookieProviderItem item;
            int index;

            foreach (ICookieProvider provider in CookiesManager.GetAllProviders())
            {
                item  = new CookieProviderItem(provider);
                index = _cookieProvidersBox.Items.Add(item);
                if (item.ToString() == providerName)
                {
                    _cookieProvidersBox.SelectedIndex = index;
                }
            }
            item  = new CookieProviderItem(null);
            index = _cookieProvidersBox.Items.Add(item);
            if (item.ToString() == providerName)
            {
                _cookieProvidersBox.SelectedIndex = index;
            }
            _cookieProvidersBox.ResumeLayout();
        }
Example #18
0
    public static bool login(string text1, string text2)
    {
        bool login_state = false;

        string _pass = EncryptDecryptString.Encrypt(text2, "Taj$$Key");

        // create filter paramters
        string[,] _params = { { "UserName", text1 }, { "Password", _pass } };

        // get all of data.
        var _ds = new Select().SelectLists("Users_Login", _params);

        var dt = _ds.Tables[0];

        if (dt.Rows.Count > 0)
        {
            SessionManager.Current.ID   = string.Format("{0}", dt.Rows[0][0]);
            SessionManager.Current.Name = string.Format("{0}", dt.Rows[0][1]);
            //SessionManager.Current.Level = string.Format("{0}", dt.Rows[0][2]);

            CookiesManager.SaveCoockie();

            login_state = true;
        }

        return(login_state);
    }
Example #19
0
        public object Save(int lifeTime)
        {
            try
            {
                if (lifeTime > 0)
                {
                    CookiesManager.SetLifeTime(lifeTime);

                    MessageService.Send(HttpContext.Current.Request, MessageAction.CookieSettingsUpdated);
                }

                return(new
                {
                    Status = 1,
                    Message = Resources.Resource.SuccessfullySaveSettingsMessage
                });
            }
            catch (Exception e)
            {
                return(new
                {
                    Status = 0,
                    Message = e.Message.HtmlEncode()
                });
            }
        }
Example #20
0
        public async Task <List <Message> > GetDialog(int id, int Page = 0)
        {
            int Id = CookiesManager.GetIdByGuid(new Guid(Request.Cookies["AccountId"]));

            List <Message> Messages = await db
                                      .Messages
                                      .Where(x => (x.GetterId == id && x.SenderId == Id)
                                             ||
                                             (x.GetterId == Id && x.SenderId == id))
                                      .ToListAsync();

            Messages.ForEach(Message =>
            {
                if (string.IsNullOrEmpty(Message.ReadTime) && Message.GetterId == Id)
                {
                    Message.ReadTime = DateTime.Now.ToString();
                }
            });

            Messages.Reverse();

            Messages = Messages
                       .Skip(MessagesCount * Page)
                       .Take(MessagesCount)
                       .ToList();

            await db.SaveChangesAsync();

            return(Messages);
        }
Example #21
0
 /// <summary>
 /// 验证用户信息并把用户信息和学校信息记录到Session
 /// </summary>
 /// <param name="user"></param>
 /// <param name="schoolId"></param>
 /// <returns></returns>
 private bool loginHandle(string cardNo)
 {
     //this.UserSchoolInfo = handler.GetSingleSchoolInfo(schoolId);
     //AMS_School school = new AMS_School();
     //school.ConnectionString = ConfigurationManager.ConnectionStrings["ConnStr"].ToString();
     //UserSchoolInfo = school;
     ////ConfigurationSettings.AppSettings["ConnStr"];
     //if (string.IsNullOrEmpty(UserSchoolInfo.ConnectionString))
     //{
     //    return false;
     //}
     try
     {
         LoginUserInfo = handler.GetReaderInfoByCardNo(cardNo);
         return(true);
     }
     catch (RemoteServiceLinkFailed ex)
     {
         Session.Clear();
         CookiesManager.RemoveCookies("userInfo");
         return(false);
     }
     catch (Exception ex)
     {
         Session.Clear();
         CookiesManager.RemoveCookies("userInfo");
         return(false);
     }
 }
Example #22
0
 /// <summary>
 /// 验证用户信息并把用户信息和学校信息记录到Session
 /// </summary>
 /// <param name="user"></param>
 /// <param name="schoolId"></param>
 /// <returns></returns>
 private bool loginHandle(UserInfo user)
 {
     //this.UserSchoolInfo = handler.GetSingleSchoolInfo(schoolId);
     AMS.Model.AMS_School school = new AMS.Model.AMS_School();
     school.ConnectionString = ConfigurationManager.ConnectionStrings["ConnStr"].ToString();
     this.UserSchoolInfo     = school;
     //ConfigurationSettings.AppSettings["ConnStr"];
     if (string.IsNullOrEmpty(this.UserSchoolInfo.ConnectionString))
     {
         return(false);
     }
     try
     {
         this.LoginUserInfo = handler.CheckAndGetReaderInfo(user, this.UserSchoolInfo);
         return(true);
     }
     catch (RemoteServiceLinkFailed ex)
     {
         spanWarmInfo.Visible   = true;
         spanWarmInfo.InnerText = string.Format("连接学校服务器失败,可能是学校已经关闭了服务器的远程访问。");
         Session.Clear();
         CookiesManager.RemoveCookies("userInfo");
         return(false);
     }
     catch (Exception ex)
     {
         spanWarmInfo.Visible   = true;
         spanWarmInfo.InnerText = string.Format("登录失败:{0}", ex.Message);
         Session.Clear();
         CookiesManager.RemoveCookies("userInfo");
         return(false);
     }
 }
Example #23
0
    void LoginUSers(string _email, string _pass)
    {
        var emp = new AdminManager().AdminsLogin(_email, _pass);

        if (emp != null)
        {
            ClientSession.Current.loginId   = emp.id;
            ClientSession.Current.loginName = emp.name;

            CookiesManager.SaveCoockie(); // save this data in cookie.

            // Redirect to the last opened page in admin.
            // Redirect to the last opened page in the system.
            string[] operators = { "default.aspx", "adm-tunr/", "default" };
            // Redirect to the last opened page in the system.
            string rURL  = Request.UrlReferrer.AbsoluteUri.ToLower();
            bool   check = operators.Any(x => rURL.EndsWith(x));

            if (!check)
            {
                Response.RedirectPermanent(rURL);
            }
            else
            {
                Response.RedirectPermanent("home.aspx");
            }
        }
        else
        {
            lblError.Text = Resources.AdminResources_en.ErrorLogin;
        }
    }
Example #24
0
        private void UserAuth(UserInfo user)
        {
            if (SecurityContext.IsAuthenticated)
            {
                return;
            }

            if (StudioSmsNotificationSettings.IsVisibleAndAvailableSettings && StudioSmsNotificationSettings.Enable)
            {
                Response.Redirect(Request.AppendRefererURL(Confirm.SmsConfirmUrl(user)), true);
                return;
            }
            if (TfaAppAuthSettings.IsVisibleSettings && TfaAppAuthSettings.Enable)
            {
                Response.Redirect(Request.AppendRefererURL(Confirm.TfaConfirmUrl(user)), true);
                return;
            }
            try
            {
                CookiesManager.AuthenticateMeAndSetCookies(user.Tenant, user.ID, MessageAction.LoginSuccess);
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
Example #25
0
 private void CheckPermission()
 {
     if (!SecurityContext.IsAuthenticated)
     {
         try
         {
             if (!TenantExtra.GetTenantQuota().HasBackup)
             {
                 throw new Exception(Resource.ErrorNotAllowedOption);
             }
             if (!SecurityContext.AuthenticateMe(CookiesManager.GetCookies(CookiesType.AuthKey)))
             {
                 throw GenerateException(HttpStatusCode.Unauthorized, "Unauthorized", null);
             }
             else
             {
                 if (!CoreContext.UserManager.IsUserInGroup(SecurityContext.CurrentAccount.ID, ASC.Core.Users.Constants.GroupAdmin.ID))
                 {
                     throw GenerateException(HttpStatusCode.Unauthorized, "Permission denied", null);
                 }
             }
         }
         catch (Exception exception)
         {
             throw GenerateException(HttpStatusCode.Unauthorized, "Unauthorized", exception);
         }
     }
 }
Example #26
0
 public static void ProcessLogout()
 {
     //logout
     CookiesManager.ClearCookies(CookiesType.AuthKey);
     CookiesManager.ClearCookies(CookiesType.SocketIO);
     SecurityContext.Logout();
 }
        protected void LoginToPortal()
        {
            try
            {
                var passwordHash = Request["passwordHash"];
                if (string.IsNullOrEmpty(passwordHash))
                {
                    throw new Exception(Resource.ErrorPasswordEmpty);
                }

                SecurityContext.SetUserPasswordHash(User.ID, passwordHash);
                MessageService.Send(Request, MessageAction.UserUpdatedPassword);

                CookiesManager.ResetUserCookie();
                MessageService.Send(Request, MessageAction.CookieSettingsUpdated);
            }
            catch (SecurityContext.PasswordException)
            {
                ShowError(Resource.ErrorPasswordRechange, false);
                return;
            }
            catch (Exception ex)
            {
                ShowError(ex.Message, false);
                return;
            }

            Response.Redirect(CommonLinkUtility.GetDefault());
        }
        public string ProcessLogOut()
        {
            var cm = CookiesManager <V_User_Information> .GetInstance();

            cm.Remove(CostCookies.COOKIES_KEY_LOGIN);
            return("ok");
        }
        private static String GetModuleResource(string typeName, string key)
        {
            try
            {
                var type    = Type.GetType(typeName, true);
                var manager = (ResourceManager)type.InvokeMember(
                    "resourceMan",
                    BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetField | BindingFlags.Public, null, type, null);

                //custom
                if (!SecurityContext.IsAuthenticated)
                {
                    SecurityContext.AuthenticateMe(CookiesManager.GetCookies(CookiesType.AuthKey));
                }

                var u       = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);
                var culture = !string.IsNullOrEmpty(u.CultureName) ? CultureInfo.GetCultureInfo(u.CultureName) : CoreContext.TenantManager.GetCurrentTenant().GetCulture();
                return(manager.GetString(key, culture));
            }
            catch (Exception err)
            {
                LogManager.GetLogger("ASC.Web.Template").Error(err);
                return(string.Empty);
            }
        }
Example #30
0
    public static object login(string text1, string text2)
    {
        // create filter paramters
        string _pass = EncryptDecryptString.Encrypt(text2, "Taj$$Key");

        string[,] _params = { { "Username", text1 }, { "Password", _pass } };
        // get all of data.
        var _ds = new Select().SelectLists("Clients_Login", _params);
        var dt  = _ds.Tables[0];

        object result = new { Status = false, Name = "" };

        if (dt.Rows.Count > 0)
        {
            SessionManager.Current.ID   = string.Format("{0}", dt.Rows[0][0]);
            SessionManager.Current.Name = string.Format("{0}", dt.Rows[0][1]);
            CookiesManager.SaveCoockie();

            result = new
            {
                Status = true,
                Name   = SessionManager.Current.Name
            };
        }
        return(result);
    }