예제 #1
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="account">账户</param>
 /// <param name="passwrod">密码</param>
 /// <param name="type">登陆类型</param>
 public Passport(string account, string passwrod, LoginType type)
 {
     Password = passwrod;
     Account = account;
     Type = type;
     State = UserState.Registerd;
 }
 public static F1OAuthTicket Authorize(F1OAuthTicket ticket, string username, string password, LoginType loginType, bool isStaging = false, bool useDemo = false)
 {
     Client client = new Client(ticket);
     var authUrl = isStaging ? string.Format("https://{0}.staging.fellowshiponeapi.com/", ticket.ChurchCode) : string.Format("https://{0}.fellowshiponeapi.com/", ticket.ChurchCode);
     authUrl += "v1/" + loginType.ToString() + "/AccessToken";
     return BuildTicket(ticket, username, password, client, authUrl);
 }
예제 #3
0
        public static bool CheckUserSecurity(LoginType expectedType)
        {
            bool isSuccess = true;

            var sessionLogin = HttpContext.Current.Session[LoginHelper.UserLoginSessionID];

            if (sessionLogin == null)
                return false;

            string userLogin = sessionLogin.ToString();

            // se cosulta el login

            using (var context = new multilingualEntities())
            {
                login currentLogin =
                    (
                        from l in context.logins
                        where l.Login1.Equals(userLogin)
                        select l
                    ).FirstOrDefault<login>();

                LoginType currentType = (LoginType)currentLogin.Type.Value;

                if (currentType == LoginType.Admin)
                    return true;

                if (expectedType != currentType)
                    isSuccess = false;
            }

            return isSuccess;
        }
예제 #4
0
        public static void Login(LoginType type)
        {
            var login = new LoginWindow(type);

            if(!IsTokenFromDatabase[type])
                login.ShowDialog();
        }
예제 #5
0
		public static void OnAppStart(Version version, LoginType loginType, bool isNew)
		{
			if(!Config.Instance.GoogleAnalytics)
				return;
			Google.TrackPageView($"/app/v{version.ToVersionString()}/{loginType.ToString().ToLower()}{(isNew ? "/new" : "")}", "");
			WritePoint(new InfluxPointBuilder("hdt_app_start").Tag("version", version.ToVersionString()).Tag("login_type", loginType).Tag("new", isNew).Build());
		}
예제 #6
0
 /// <summary>
 ///     Creates a new instance of a NetChannel.
 /// </summary>
 /// <param name="manager">The server this channel belongs to.</param>
 /// <param name="connection">The raw NetConnection to the remote peer.</param>
 internal NetChannel(NetManager manager, NetConnection connection, NetUserId userId, string userName, LoginType loginType)
 {
     _manager    = manager;
     _connection = connection;
     UserId      = userId;
     UserName    = userName;
     AuthType    = loginType;
 }
 /// <summary>
 ///     Creates a new instance of a NetChannel.
 /// </summary>
 /// <param name="manager">The server this channel belongs to.</param>
 /// <param name="connection">The raw NetConnection to the remote peer.</param>
 internal NetChannel(NetManager manager, NetConnection connection, NetUserData userData,
                     LoginType loginType)
 {
     _manager    = manager;
     _connection = connection;
     AuthType    = loginType;
     UserData    = userData;
 }
예제 #8
0
 public Session(string user, DateTime exp, LoginType loginType, String macAddress)
 {
     Id              = UInt64.MaxValue;
     Username        = user;
     Exp             = exp;
     this.LoginType  = loginType;
     this.MacAddesse = macAddress;
 }
예제 #9
0
 public ReqReg(LoginType type, string nick, string name, string pass, string code) : base(MsgID.ReqReg)
 {
     this.type = type;
     this.name = name;
     this.pass = pass;
     this.nick = nick;
     this.code = code;
 }
예제 #10
0
파일: User.cs 프로젝트: Avatarchik/Lemming
    public void StartWithoutLogin(Action successCallback)
    {
        loginSuccessCallback = successCallback;
        loginType            = LoginType.Guest;
        userID = SystemInfo.deviceUniqueIdentifier;

        LoginToGameServer();
    }
예제 #11
0
파일: LoginForm.cs 프로젝트: davidajulio/hx
 public LoginForm(LoginType login)
 {
     //
     // Required for Windows Form Designer support
     //
     InitializeComponent();
     this.login = login;
 }
예제 #12
0
        public void AuthService_Login_ExistingUser_ValidCredentialsAndUserApproved_ConfirmedEmail_2FAEmailLoginType_Success()
        {
            // Arrange
            LoginType expectedLoginType = LoginType.TwoFactorViaEmail;

            // Arrange & Act & Assert
            AuthService_Login_ValidLoginProcess(expectedLoginType);
        }
예제 #13
0
 public void Reset()
 {
     IsConnected     = false;
     Name            = string.Empty;
     FacebookToken   = string.Empty;
     FacebookId      = string.Empty;
     UserToken       = string.Empty;
     PlayerLoginType = LoginType.None;
 }
예제 #14
0
 /// <summary>Runs the given delegate as the given user, optionally executing it in a new thread. The user name can be in either
 /// DOMAIN\user or user@domain format.
 /// </summary>
 public static void RunWithImpersonation(string userName, string password, LoginType loginType, bool runInANewThread,
                                         Action code)
 {
     if (code == null)
     {
         throw new ArgumentException();
     }
     Run(LogOnUser(GetDomain(userName), GetUserName(userName), password, loginType), true, code, runInANewThread);
 }
예제 #15
0
 public static void OnAppStart(Version version, LoginType loginType, bool isNew)
 {
     if (!Config.Instance.GoogleAnalytics)
     {
         return;
     }
     Google.TrackPageView($"/app/v{version.ToVersionString()}/{loginType.ToString().ToLower()}{(isNew ? "/new" : "")}", "");
     WritePoint(new InfluxPointBuilder("hdt_app_start").Tag("version", version.ToVersionString()).Tag("login_type", loginType).Tag("new", isNew).Build());
 }
예제 #16
0
        private static void UpdateLoginInfo(LoginType loginType, RiBaoAuthoInfo info)
        {
            StorageInfo.Instance.LoginType      = loginType;
            StorageInfo.Instance.ZhiHuAuthoInfo = info;
            Storager.UpdateStorageInfo();

            IsLogin = true;
            SetHttpAuthorization();
        }
예제 #17
0
 public LoginChallengeProof(string userData, LoginType loginType, int?partnerID, string challenge1, string challenge2, string passwordHash)
 {
     UserData     = userData;
     LoginType    = loginType;
     PartnerID    = partnerID;
     Challenge1   = challenge1;
     Challenge2   = challenge2;
     PasswordHash = passwordHash;
 }
예제 #18
0
 public ChallengeProofData(string userData, LoginType loginType, uint partnerID, string challenge1, string challenge2, string passwordHash)
 {
     UserData     = userData ?? throw new ArgumentNullException(nameof(userData));
     LoginType    = loginType;
     PartnerID    = partnerID;
     Challenge1   = challenge1 ?? throw new ArgumentNullException(nameof(challenge1));
     Challenge2   = challenge2 ?? throw new ArgumentNullException(nameof(challenge2));
     PasswordHash = passwordHash ?? throw new ArgumentNullException(nameof(passwordHash));
 }
예제 #19
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            LoginType loginType = await db.LoginTypes.FindAsync(id);

            db.LoginTypes.Remove(loginType);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
예제 #20
0
 public User(Guid id, string login, string password, LoginType type, Guid activationCode, bool isActive)
 {
     Id             = id;
     Login          = login;
     Password       = password;
     Type           = type;
     ActivationCode = activationCode;
     IsActive       = isActive;
 }
예제 #21
0
        public static void GetUserById(long id, LoginType loginType)
        {
            string token = RedisHelper.Get <string>($"UserInfo_{id}");

            if (!string.IsNullOrEmpty(token))
            {
                Del(loginType, token, id);
            }
        }
예제 #22
0
        public void LoginAs(LoginType loginType)
        {
            string method = "POST";

            Tuple <string, string>[] dataParameters = { Tuple.Create("type", loginType.ToString().ToLowerInvariant()) };
            Tuple <string, string>[] urlParameters  = { Tuple.Create("action", "set-locale"), Tuple.Create("json", "1") };

            Controller.Call <dynamic>(method, "users", dataParameters, urlParameters);
        }
예제 #23
0
 public void Clear()
 {
     // loginType
     loginType_ = 0;
     // version
     version_ = 0;
     // accToken
     accToken_ = "";
 }
예제 #24
0
        public void SendCredentials(LoginType type, string userID = "", string password = "")
        {
            loginType     = type;
            this.userID   = userID;
            this.password = password;

            byte[]  stream        = null;
            MsgCode serverChannel = MsgCode.LoginMessage;

            switch (type)
            {
            case LoginType.Guest:
            {
                return;
            }

            case LoginType.Login:
            {
                LoginC2S loginData = new LoginC2S();

                loginData.loginName = userID;
                loginData.password  = password;
                loginData.UDID      = DeviceUtil.Instance.GetDeviceUniqueIdentifier();
                loginData.MAC       = DeviceUtil.Instance.GetDeviceUniqueIdentifier();
                loginData.ip        = DeviceUtil.Instance.GetDeviceIP();

                stream        = ProtobufUtils.Serialize(loginData);
                serverChannel = MsgCode.LoginMessage;

                UILockManager.SetGroupState(UIEventGroup.Middle, UIEventState.WaitNetwork);

                break;
            }

            case LoginType.Register:
            {
                RegisterC2S register = new RegisterC2S();

                register.ip        = DeviceUtil.Instance.GetDeviceIP();
                register.MAC       = DeviceUtil.Instance.GetDeviceUniqueIdentifier();
                register.loginName = userID;
                register.passWord  = password;

                stream        = ProtobufUtils.Serialize(register);
                serverChannel = MsgCode.RegisterMessage;

                UILockManager.SetGroupState(UIEventGroup.Middle, UIEventState.WaitNetwork);

                break;
            }
            }

            Utils.DebugUtils.Log(Utils.DebugUtils.Type.Login, string.Format("SendCredentials {0} userID: {1} password: {2}", serverChannel.ToString(), userID, password));
            Utils.DebugUtils.Log(Utils.DebugUtils.Type.Login, string.Format("Sending {0} as {1} ", type == LoginType.Register ? "RegisterC2S" : "LoginC2S", serverChannel.ToString()));
            NetworkManager.SendRequest(serverChannel, stream);
        }
예제 #25
0
        private bool Authorize(LoginType type, bool simple = false)
        {
            bool result = false;

            if (Options.CurrentOptions.Authorize)
            {
                LoginForm f = new LoginForm(type);

                IsDialogOpen = true;
                DialogResult dr = f.ShowDialog();
                IsDialogOpen = false;

                if (dr == DialogResult.Yes)
                {
                    result = true;
                }
                else
                {
                    result = false;
                }
            }
            else
            {
                if (simple)
                {
                    return(true);
                }

                string title = string.Empty;
                switch (type)
                {
                case LoginType.Remove:
                    title = "Delete account?";
                    break;

                case LoginType.RemoveAll:
                    title = "Delete all accounts?";
                    break;
                }

                IsDialogOpen = true;
                DialogResult dr = MessageBox.Show("Are you sure you want to do this?", title, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                IsDialogOpen = false;

                if (dr == DialogResult.Yes)
                {
                    result = true;
                }
                else
                {
                    result = false;
                }
            }

            return(result);
        }
예제 #26
0
 protected void CBTHook_Activate(IntPtr handle)
 {
     if (IsLoginWindows(handle))
     {
         string    title     = GetHandleText(handle);
         LoginType loginType = GetLoginType(title);
         string    name      = RemoveStringPreFlag(title);
         OnPaddingProcess(handle, name, loginType);
     }
 }
예제 #27
0
        private void SetIssuerAddress(RedirectContext context, LoginType loginType)
        {
            if (context.ProtocolMessage.RequestType != OpenIdConnectRequestType.Token)
            {
                var settings = context.HttpContext.RequestServices.GetService <IdentitySettings>();

                var upParty = GetUpParty(settings, loginType);
                context.ProtocolMessage.IssuerAddress = context.ProtocolMessage.IssuerAddress.Replace($"/{settings.DownParty}/", $"/{settings.DownParty}({upParty})/");
            }
        }
예제 #28
0
 public ActionResult Edit([Bind(Include = "LoginTypeID,LoginTypeName")] LoginType loginType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(loginType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(loginType));
 }
예제 #29
0
        public IViewComponentResult Invoke(LoginType current)
        {
            var model = new LoginTabsViewModel();

            model.Options = _settingManager.GetApplicationOptions <LoginOptions>(nameof(LoginOptions));

            model.CurrentLoginType = current;

            return(View(model));
        }
예제 #30
0
 public Login(
     int id,
     string username,
     string password,
     LoginType type,
     string nameFirst,
     string nameLast) : this(username, password, type, nameFirst, nameLast)
 {
     LoginId = id;
 }
예제 #31
0
 public void Login_53_EmptyFields()
 {
     //Test Data preparation
     username         = "";
     password         = "";
     otp              = "";
     timeBeforeSubmit = noTime;
     loginType        = LoginType.InValidCredentials;
     workflow.Login(username, password, otp, timeBeforeSubmit, loginType, userRole);
 }
예제 #32
0
        public static string GetLoginAttribute(string file, LoginType Type, LogicInformation attribute)
        {
            XElement root = XElement.Load(file);

            XElement elem = root
                            .Elements(LoginType.Accout.ToString())
                            .Single(itemName => itemName.Attribute(LoginType.LogicType.ToString()).Value == Type.ToString());

            return(elem.Attribute(attribute.ToString()).Value);
        }
예제 #33
0
 public User(string id, string token, string firstName, string lastName, string email, string imageUrl, LoginType type)
 {
     Id                   = id;
     Token                = token;
     FirstName            = firstName;
     LastName             = lastName;
     Email                = email;
     Picture              = imageUrl;
     CurrentUserLoginType = type;
 }
예제 #34
0
        public static async ETModel.ETVoid Login(string account, string password, LoginType loginType)
        {
            var netOuterComponent = ETModel.Game.Scene.GetComponent <ETModel.NetOuterComponent>();
            // model层session
            var modelSession = netOuterComponent.Create(ETModel.GlobalConfigComponent.Instance.GlobalProto.Address);
            //新建个ETHotfix层session,基于model层session进行通信
            var realmSession            = ComponentFactory.Create <Session, ETModel.Session>(modelSession);
            R2C_LandlordsLogin r2CLogin = null;

            switch (loginType)
            {
            case LoginType.LOGIN:
                r2CLogin = (R2C_LandlordsLogin)await realmSession.Call(new C2R_LandlordsLogin()
                {
                    Account = account, Password = password
                });

                break;

            case LoginType.REGIST:
                r2CLogin = (R2C_LandlordsLogin)await realmSession.Call(new C2R_LandlordsRegist()
                {
                    Account = account, Password = password
                });

                break;
            }
            realmSession.Dispose();
            if (r2CLogin.Error != 0)
            {
                Log.Error(r2CLogin.Message);
                return;
            }

            // model层session
            var gateSession = netOuterComponent.Create(r2CLogin.Address);

            ETModel.Game.Scene.AddComponent <ETModel.SessionComponent>().Session = gateSession;

            // 在ETHotfix层保留一份方便后面使用
            Game.Scene.AddComponent <SessionComponent>().Session = ComponentFactory.Create <Session, ETModel.Session>(gateSession);

            var g2CLoginGate = (G2C_LandlordsLoginGate)await SessionComponent.Instance.Session.Call(new C2G_LandlordsLoginGate()
            {
                Key = r2CLogin.Key
            });

            Log.Info("登陆成功!");

            var player = ETModel.ComponentFactory.CreateWithId <ETModel.Player>(g2CLoginGate.PlayerId);

            ETModel.PlayerComponent.Instance.MyPlayer = player;

            // Game.EventSystem.Run();
        }
예제 #35
0
        /// <summary>
        /// Starts authorization process. Opens and requests for access if VK App is installed.
        /// Otherwise SDK will navigate current app to SDK navigation page and start OAuth in WebBrowser.
        /// </summary>
        /// <param name="scopeList">List of permissions for your app</param>
        /// <param name="revoke">If true user will be allowed to logout and change user</param>
        /// <param name="forceOAuth">SDK will use only OAuth authorization via WebBrowser</param>
        public static void Authorize(List <String> scopeList, bool revoke = false, bool forceOAuth = false,
                                     LoginType loginType = LoginType.WebView)
        {
            try
            {
                CheckConditions();
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
                return;
            }

            if (scopeList == null)
            {
                scopeList = new List <string>();
            }

            // Force OFFLINE scope using
            if (!scopeList.Contains(VKScope.OFFLINE))
            {
                scopeList.Add(VKScope.OFFLINE);
            }


            switch (loginType)
            {
            case LoginType.VKApp:
#if SILVERLIGHT
#if DEBUG
                MessageBox.Show("Currently only the webview authentication is supported for Silverlight apps.");
#endif

                // do not currently support vk app authorization
                RootFrame.Navigate(new Uri(string.Format(VK_NAVIGATE_STR_FRM, string.Join(",", scopeList), revoke), UriKind.Relative));
#else
                AuthorizeVKApp(scopeList, revoke);
#endif
                break;

            default:
#if SILVERLIGHT
                RootFrame.Navigate(new Uri(string.Format(VK_NAVIGATE_STR_FRM, string.Join(",", scopeList), revoke), UriKind.Relative));
#else
                var loginUserControl = new VKLoginUserControl();

                loginUserControl.Scopes = scopeList;
                loginUserControl.Revoke = revoke;

                loginUserControl.ShowInPopup(Windows.UI.Xaml.Window.Current.Bounds.Width,
                                             Windows.UI.Xaml.Window.Current.Bounds.Height);
#endif
                break;
            }
        }
예제 #36
0
 public Package(string gameName, string gameDir, string versionNumber, Uri updateURL, Uri descURL, GameType typeGame, LoginType typeLogin, string commandLine)
 {
     GameName = gameName;
     GameDir = gameDir;
     VersionNumber = versionNumber;
     UpdateURL = updateURL;
     DescURL = descURL;
     TypeGame = typeGame;
     TypeLogin = typeLogin;
     CommandLine = commandLine;
 }
        private void SetAudit(object entity, EventType eventType)
        {
            var headerPublicKey = HttpContext.Current.Request.Headers[GlobalConstants.PublicKey];
            var headerLoginType = HttpContext.Current.Request.Headers[GlobalConstants.LoginType];
            var loginType       = new LoginType().ConvertToCollection().FirstOrDefault(loginTp => loginTp.Value == int.Parse(headerLoginType));

            var id = GlobalConstants.SystemUserId;

            if (loginType.Value == LoginType.User.GetValue())
            {
                id = _hmacHelper.FindUserByPublicKey(headerPublicKey).Id;
            }

            if (loginType.Value == LoginType.Worker.GetValue())
            {
                id = _hmacHelper.FindWorkerByPublicKey(headerPublicKey).Id;
            }

            //const int id = 1;
            var entityToAudit = entity as IAuditInfo;
            var today         = DateTime.Now.ToDateTimeString().DateTimeStringToDateTime();

            switch (eventType)
            {
            case EventType.Create:
                entityToAudit.CreatedOn  = today;
                entityToAudit.ModifiedOn = today;
                entityToAudit.CreatedBy  = id;
                entityToAudit.ModifiedBy = id;
                entityToAudit.Status     = GlobalConstants.StatusActivated;
                if (entity is IDeletable)
                {
                    var entityDeletable = entity as IDeletable;
                    entityDeletable.IsActive = GlobalConstants.Activated;
                }
                break;

            case EventType.Update:
                entityToAudit.ModifiedBy = id;
                entityToAudit.ModifiedOn = today;
                break;

            case EventType.Delete:
                entityToAudit.ModifiedBy = id;
                entityToAudit.ModifiedOn = today;
                entityToAudit.Status     = GlobalConstants.StatusDeactivated;
                if (entity is IDeletable)
                {
                    var entityDeletable = entity as IDeletable;
                    entityDeletable.IsActive = GlobalConstants.Deactivated;
                }
                break;
            }
        }
예제 #38
0
        public IUserSnap Load(string securityToken, LoginType type)
        {
            CookieContainer cc = new CookieContainer();

            Cookie ck = new Cookie(WebConfiguration.Instance.ConfigSecurityTokenName, securityToken);
            ck.Domain = string.IsNullOrEmpty(WebConfiguration.Instance.ConfigDomainName) ? "localhost" : WebConfiguration.Instance.ConfigDomainName;
            cc.Add(ck);

            string ret = HttpHelper.SendRequest(_resource, null, cc, "POST", "utf-8");
            if (string.IsNullOrEmpty(ret)) return null;
            return ret.ToObject<UserSnap>(Encoding.UTF8);
        }
예제 #39
0
        public LoginInfo(string u, string f, string l, string p, string m, bool su, bool sa)
        {
            URI = u;
            FirstName = f;
            LastName = l;
            Password = p;
            LoginMode = LoginType.NONE;
            ShowURI = su;
            ShowAccount = sa;

            LoginMode = GetLoginType(m);
        }
예제 #40
0
		/// <summary>
		/// Constructor. Starts the impersonation with the given credentials.
		/// Please note that the account that instantiates the Impersonator class
		/// needs to have the 'Act as part of operating system' privilege set.
		/// </summary>
		/// <param name="userName">The name of the user to act as.</param>
		/// <param name="domainName">The domain name of the user to act as.</param>
		/// <param name="password">The password of the user to act as.</param>
		/// <param name="loginType">The login type.</param>
		public Impersonator(
			string userName,
			string domainName,
			string password,
			LoginType loginType )
		{
			ImpersonateValidUser(
				userName,
				domainName,
				password,
				loginType );
		}
예제 #41
0
		public static void OnAppStart(Version version, LoginType loginType, bool isNew)
		{
			if(!Config.Instance.GoogleAnalytics)
				return;
			var point = new InfluxPointBuilder("hdt_app_start").Tag("version", version.ToVersionString()).Tag("login_type", loginType).Tag("new", isNew);
#if(SQUIRREL)
			point.Tag("squirrel", true);
#else
			point.Tag("squirrel", false);
#endif
			WritePoint(point.Build());
		}
예제 #42
0
 public IUserSnap GetUser(string securitytoken, LoginType type)
 {
     IUserSnap snap = _session_manager.Get(securitytoken);
     if (snap == null)
     {
         _usersnap_loader.SetResource(WebConfiguration.Instance.WebUpdateUserAddress);
         snap = _usersnap_loader.Load(securitytoken, type);
         if (snap == null) return snap;
         _session_manager.Add(snap);
     }
     return snap;
 }
예제 #43
0
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            //_id = httpContext.GetToken(WebConfiguration.Instance.ConfigIdTokenName);
            //_account = httpContext.GetToken(WebConfiguration.Instance.ConfigAccountTokenName);
            //_securitykey = httpContext.GetToken(WebConfiguration.Instance.ConfigSecurityTokenName);

            //if (string.IsNullOrEmpty(_id) || string.IsNullOrEmpty(_account) || string.IsNullOrEmpty(_securitykey))
            //    return false;

            _logintype = httpContext.GetHeader(WebConfiguration.Instance.ConfigHeaderTypeName).ToEnum<LoginType>(LoginType.Web);
            //_code = httpContext.GetHeader(WebConfiguration.Instance.ConfigHeaderCodeName);

            return Reception.Instance.IsAuthorized(httpContext, _logintype);
        }
예제 #44
0
		public static void OnAppStart(Version version, LoginType loginType, bool isNew, int startupDuration)
		{
			if(!Config.Instance.GoogleAnalytics)
				return;
			var point = new InfluxPointBuilder("hdt_app_start")
				.Tag("version", version.ToVersionString()).Tag("login_type", loginType).Tag("new", isNew)
				.Tag("auto_upload", Config.Instance.HsReplayAutoUpload)
				.Field("startup_duration", startupDuration);
#if(SQUIRREL)
			point.Tag("squirrel", true);
#else
			point.Tag("squirrel", false);
#endif
			WritePoint(point.Build());
		}
예제 #45
0
        public bool IsAuthorized(HttpContextBase context, LoginType type)
        {
            var _id = context.GetToken(WebConfiguration.Instance.ConfigIdTokenName);
            var _account = context.GetToken(WebConfiguration.Instance.ConfigAccountTokenName);
            var _securitykey = context.GetToken(WebConfiguration.Instance.ConfigSecurityTokenName);

            if (string.IsNullOrEmpty(_id) || string.IsNullOrEmpty(_account) || string.IsNullOrEmpty(_securitykey))
                return false;
            var _code = string.Empty;
            if (type == LoginType.Web)
                _code = context.GetIP();
            else _code = context.GetHeader(WebConfiguration.Instance.ConfigHeaderCodeName);

            var snap = new UserSnap() { Id = _id, Account = _account, SecurityKey = _securitykey, LoginType = type, LoginCode = _code };
            return Reception.Instance.IsAuthorized(snap);
        }
예제 #46
0
 public ComRet CheckIn(string account, string password, LoginType type, string code)
 {
     var pp = MongoEntity.Get<Passport>(p => p.Account == account);
     if (pp == null) return Result("用户名不正确");
     if (pp.Password != password) return Result("密码不正确");
     if (type == LoginType.Web && pp.WebCode != code)
     {
         pp.WebCode = code;
         pp.Save();
     }
     else if (type != LoginType.Web && pp.ClientCode != code)
     {
         pp.ClientCode = code;
         pp.Save();
     }
     return Result(true, pp.SecurityKey);
 }
예제 #47
0
        protected void CheckIn(string account, string securitykey, LoginType type, string code)
        {
            var user = GetService<IProfile>().GetUserSnap(securitykey, type);
            user.LoginType = type;
            user.LoginCode = code;
            if (user == null || user.Account != account) return;
            //IUserInfo user = new UserInfo() { Id = userinfo.Id, Account = userinfo.Account, Name = userinfo.Name, Email=userinfo.Email, Origin= userinfo.Origin, RegisterdTime = userinfo. };
            if (Reception.Instance.IsAuthorized(user))
                Reception.Instance.SaveCookies(HttpContext, user);
            Log(user.Name + " Checked In");

            //WinWebGlobalManager.Reception.Login(HttpContext, user);

            //var key = string.Format("{0}_{1}_{2}", profile.Account, DateTime.Now.ToString("yyyyMMddHHmmssffff"), profile.Id).ToMD5();
            //HttpContext.SaveCookie(Consts.CookieName, key, Consts.CookieDomain, Consts.CookieTimeout);
            //HttpContext.SaveToSession(key, profile);
        }
        public LoginForm(LoginType loginReason = LoginType.Initial, SteamGuardAccount account = null)
        {
            InitializeComponent();
            this.LoginReason = loginReason;
            this.androidAccount = account;

            if (this.LoginReason != LoginType.Initial)
            {
                txtUsername.Text = account.AccountName;
                txtUsername.Enabled = false;
            }

            if(this.LoginReason == LoginType.Refresh)
            {
                labelLoginExplanation.Text = "Your Steam credentials have expired. For trade and market confirmations to work properly, please login again.";
            }
        }
예제 #49
0
 private void ExecuteLogin(LoginType login, String name)
 {
     try
     {
         if(new LoginForm(login).ShowDialog(this) != DialogResult.Yes)
         {
             return;
         }
         Hide();
         new UserForm(name).ShowDialog(this);
         Show();
     }
     catch(ConnectionProviderException exception)
     {
         MessageBox.Show(this, exception.Message, "Erro na ligação.",
             MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        public static void Login(LoginType loginType, Action<bool, object> loginCallback)
        {
            if (IsLogin)
                return;

            if (loginCallback == null)
                loginCallback = (b, o) => { };

            string msg = string.Empty;
            if (!CheckLoginType(loginType, out msg))
            {
                loginCallback(false, msg);
                return;
            }
            var authorizer = Authorizations[loginType];

            if (authorizer.IsAuthorized && Authorizations[loginType].LoginData != null)
            {
                LoginZhiHu(loginType, loginCallback);
            }
            else
            {
                try
                { 
                    authorizer.Login((isSuccess, res)=>
                    {
                        if(isSuccess)
                        {
                            LoginZhiHu(loginType, loginCallback);
                        }
                        else
                        {
                            loginCallback(false, StringUtil.GetString("LoginFailed"));
                        }
                    });
                }
                catch(Exception)
                {
                    loginCallback(false, StringUtil.GetString("LoginFailed"));
                }
            }
        }
예제 #51
0
 public IUserSnap GetUserSnap(string ticket, LoginType type)
 {
     var passport = MongoEntity.Get<Passport>(p => p.SecurityKey == ticket);
     if (passport == null) return null;
     var profile = MongoEntity.Get<Profile>(p => p.SecurityKey == ticket);
     if (profile == null) return null;
     IUserSnap snap = new UserSnap()
     {
         Id = profile.Id,
         SecurityKey = profile.SecurityKey,
         Name = profile.Name,
         Account = profile.Account,
         LoginCode = passport.GetLoginCode(type),
         LoginType = type,
         Email = profile.Email,
         RegisteredTime = profile.BsonObjectId.CreationTime
     };
     Log(snap.Name + " do GetUserSnap");
     return snap;
     //return new UserInfo(profile.Id, profile.Account, profile.Name, profile.Email, (profile.Native == null ? "" : string.Format("{0}{1}{2}", profile.Region.Name, profile.Nationality.Name, profile.Native.Name)), DateTime.Now, profile.SecurityKey);
 }
예제 #52
0
        private LoginWindow(LoginType type)
        {
            InitializeComponent();

            switch (type)
            {
                case LoginType.Twitch:
                {
                    var token = AccessTokenRepository.Instance.GetNotExpiredToken(AccessTokenType.Twitch);
                    if (string.IsNullOrEmpty(token))
                    {
                        WbMain.Navigating += OnNavigatingTwitch;
                        WbMain.Navigate(TwitchApiClient.AuthorizeUrl, null, null, "User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729; InfoPath.3; MALNJS)\r\n");
                    }
                    else
                    {
                        IsTokenFromDatabase[type] = true;
                        TwitchApiClient.SetToken(token);
                    }
                    break;
                }
                case LoginType.Vk:
                {
                    var token = AccessTokenRepository.Instance.GetNotExpiredToken(AccessTokenType.Vk, 3600 * 12);
                    if (string.IsNullOrEmpty(token))
                    {
                        WbMain.Navigating += OnNavigatingVk;
                        WbMain.Navigate(VkApiClient.AuthorizeUrl, null, null, "User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729; InfoPath.3; MALNJS)\r\n");
                    }
                    else
                    {
                        IsTokenFromDatabase[type] = true;
                        VkApiClient.SetToken(token);
                    }
                    break;
                }
                default:
                    throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }
 private async Task LogHistory(LoginType loginType, LoginStatus status, string clientId, string username, string deviceKey, string apiKey, string clientIp = null, string clientUri = null)
 {
     var unityContainer = UnityConfig.GetConfiguredContainer() as UnityContainer;
     var loginHistoryBll = unityContainer.Resolve<ILoginHistoryBll>();
     if (string.IsNullOrEmpty(clientIp))
         clientIp =SecurityUtils.GetClientIPAddress();
     if (string.IsNullOrEmpty(clientUri) && HttpContext.Current != null)
         clientUri = HttpContext.Current.Request.Url.AbsoluteUri;
     int num = await loginHistoryBll.InsertLoginHistory(new InsertLoginHistoryInput()
     {
         Type = loginType.GetHashCode(),
         UserName = username,
         LoginTime = DateTime.Now,
         LoginStatus = status.GetHashCode(),
         AppId = string.IsNullOrEmpty(clientId) ? null : clientId,
         ClientUri = clientUri,
         ClientIP = clientIp,
         ClientUA = HttpContext.Current.Request.UserAgent,
         ClientApiKey = apiKey,
         ClientDevice = deviceKey
     });
 }
예제 #54
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="urInfoModel"></param>
        /// <param name="loginType"></param>
        /// <returns></returns>
        public int LoginUserInfo(UserInfoModel urInfoModel,LoginType loginType)
        {
            UserInfoModel urInfoModelTmp = new UserInfoModel();

              int resultInt = 0;

              #region - sql qy -
              string selectQy = @"SELECT
                                `ID`,
                                `UserName`,
                                `Pwd`,
                                `Mail`,
                                `Mobile`,
                                `RegisterLogin`,
                                `LastLogin`,
                                `avg1`,
                                `avg2`
                              FROM `movehouse`.`userinfo` AS urInfo";
              StringBuilder sbWhere = new StringBuilder();
              sbWhere.Append(" where ");
             // sbWhere.Append(" urInfo.`Pwd`=@Pwd ");
              switch (loginType)
              {
              case LoginType.用户名:
                  sbWhere.Append("  urInfo.`UserName`=@UserName");
                  break;
              case LoginType.邮箱:
                  sbWhere.Append(" urInfo.`Mail`=@Mail");
                  break;
              case LoginType.手机:
                  sbWhere.Append(" urInfo.`Mobile`=@Mobile");
                  break;
              default:
                  break;
              }

              selectQy = selectQy + sbWhere.ToString();
              #endregion

              #region - paras -
              MySqlParameter[] paras =
               {
               new MySqlParameter("@UserName",urInfoModel.UserName)
               //    new MySqlParameter("@Pwd", urInfoModel.Pwd.ToLower()),
               };
              #endregion

              #region - Excute -

              //记录查询
              DataTable dataTable = DbHelperMySql.GetDataSet(DbHelperMySql.connectionStringManager, selectQy, paras).Tables[0];

              if (dataTable != null)
              {
              urInfoModelTmp = new UserInfoModel();
              foreach (DataRow row in dataTable.Rows)
              {
                 urInfoModelTmp=TransUserInfoModel(row);
              }
              }

              #endregion

              if (string.Equals(urInfoModelTmp.Pwd,urInfoModel.Pwd))
              {
              resultInt = 1;
              }
              return resultInt;
        }
예제 #55
0
파일: Form1.cs 프로젝트: yooyke/work
        private void LoggedIn()
        {
            loginButton.Invoke(new StringDelegate(LoginTextInvoke), new object[] { "Logout" });
            loginState = LoginType.Login;
            LoginEnabled(true);

            SaveLoginParam();
        }
예제 #56
0
파일: Form1.cs 프로젝트: yooyke/work
        private void LoggedOut()
        {
            if (exit)
                return;

            loginButton.Invoke(new StringDelegate(LoginTextInvoke), new object[] { "Login" });
            loginState = LoginType.None;
            LoginEnabled(true);
        }
예제 #57
0
파일: Form1.cs 프로젝트: yooyke/work
        private void loginButton_Click(object sender, EventArgs e)
        {
            string msg = string.Empty;

            switch (loginState)
            {
                case LoginType.None:
                    LoginEnabled(false);
                    loginState = LoginType.LoginReq;
                    Login();
                    break;
                case LoginType.Login:
                    LoginEnabled(false);
                    loginState = LoginType.LogoutReq;
                    Logout();
                    break;
            }
        }
예제 #58
0
        public User GetUserByUsername(string loginName, LoginType loginType)
        {
            using (var uow = new UnitOfWork())
            {

                if (loginName.IsNotNull() && loginName.Trim().IsNotNull() && loginName.Trim().IsNotEmpty())
                {
                    long? mobileNumber = null;
                    if (loginType == LoginType.IsMobile)
                        mobileNumber = loginName.As<long>();
                    User loginUser;
                    switch (loginType)
                    {
                        case LoginType.IsUserName:
                            loginUser = uow.GetRepository<User>().Items.Include(x => x.UserLogins.Select(y => y.UserHistories))
                                        .Include(x => x.UserInRoles
                                        .Select(y => y.Role.RoleInPermissions.Select(z => z.PermissionSet)))
                                        .FirstOrDefault(a => a.UserLogins.FirstOrDefault().UserName == loginName);
                            return loginUser;
                            break;
                        case LoginType.IsMobile:
                            loginUser = uow.GetRepository<User>().Items.Include(x => x.UserLogins.Select(y => y.UserHistories))
                                        .Include(x => x.UserInRoles
                                        .Select(y => y.Role.RoleInPermissions.Select(z => z.PermissionSet)))
                                        .FirstOrDefault(x => x.Active && x.Mobile == mobileNumber);
                            return loginUser;
                            break;
                        case LoginType.IsEmail:
                            loginUser = uow.GetRepository<User>().Items.Include(x => x.UserLogins.Select(y => y.UserHistories))
                                        .Include(x => x.UserInRoles
                                        .Select(y => y.Role.RoleInPermissions.Select(z => z.PermissionSet)))
                                        .FirstOrDefault(x => x.Active && x.Email == loginName);
                            return loginUser;
                            break;
                    }
                }
                return null;
            }

        }
예제 #59
0
        private void ComposeConnectionString(LoginType login, String password)
        {
            String userName = "";
            switch(login)
            {
                case LoginType.Clients: userName = "******"; break;
                case LoginType.Employees: userName = "******"; break;
                case LoginType.Supervisors: userName = "******"; break;
            }
            //			connectionString = @"Provider=SQLOLEDB; Data Source=LAPTOP\DAVID;" +
            //				"Initial Catalog=IsiVideo; User ID=" + userName + "; Password="******";";

            connectionString = @"Provider=SQLOLEDB; Data Source=SSICSRV2\ALUNOS;" +
                "Initial Catalog=ISI_D_6; User ID=" + userName + "; Password="******";";
        }
예제 #60
0
 public void SetPassword(IWin32Window owner, LoginType login, String password)
 {
     ComposeConnectionString(login, password);
     displayForm = new LoginWaitForm();
     new Thread(new ThreadStart(TryConnection)).Start();
     if(displayForm.ShowDialog(owner) == DialogResult.No)
     {
         throw new ConnectionProviderException("A password indicada é inválida.");
     }
 }