Beispiel #1
0
        private static void OutsideAuth()
        {
            var        action         = MessageAction.LoginSuccess;
            Func <int> funcLoginEvent = () => { return(CookiesManager.GetLoginEventId(action)); };
            var        cookie         = string.Empty;

            try
            {
                cookie = SecurityContext.AuthenticateMe(Constants.OutsideUser.ID, funcLoginEvent);
            }
            catch (Exception)
            {
                throw;
            }

            if (HttpContext.Current != null)
            {
                CookiesManager.SetCookies(CookiesType.AuthKey, cookie);
                DbLoginEventsManager.ResetCache();
            }
            else
            {
                SecurityContext.AuthenticateMe(cookie);
            }
        }
        public static string AuthenticateMeAndSetCookies(int tenantId, Guid userId, MessageAction action, bool session = false)
        {
            bool       isSuccess      = true;
            var        cookies        = string.Empty;
            Func <int> funcLoginEvent = () => { return(GetLoginEventId(action)); };

            try
            {
                cookies = SecurityContext.AuthenticateMe(userId, funcLoginEvent);
            }
            catch (Exception)
            {
                isSuccess = false;
                throw;
            }
            finally
            {
                if (isSuccess)
                {
                    SetCookies(CookiesType.AuthKey, cookies, session);
                    DbLoginEventsManager.ResetCache(tenantId, userId);
                }
            }

            return(cookies);
        }
        public static void AuthenticateMeAndSetCookies(string login, string passwordHash, MessageAction action, bool session = false)
        {
            bool       isSuccess      = true;
            var        cookies        = string.Empty;
            Func <int> funcLoginEvent = () => { return(GetLoginEventId(action)); };

            try
            {
                cookies = SecurityContext.AuthenticateMe(login, passwordHash, funcLoginEvent);
            }
            catch (Exception)
            {
                isSuccess = false;
                throw;
            }
            finally
            {
                if (isSuccess)
                {
                    SetCookies(CookiesType.AuthKey, cookies, session);
                    DbLoginEventsManager.ResetCache();
                }
            }
        }