コード例 #1
0
ファイル: KeyUser.cs プロジェクト: mailekah/AgapeConnect1
        ////First time login, for Key proxy
        public bool Login(string username, string password, string device)
        {
            if (Authenticate(username, password))
            {
                //insert those into the DB, with Key credentials along with the device and date fields
                var checkDb = new KeyEntities().AP_KeyCredentials.Where(k => ((k.KeyGuid == _keyGuid) && (k.Device == device)));

                if (checkDb.Count() == 0)
                {
                    _mobilePasscode = Guid.NewGuid();
                    StoreKeyCredentials(username, password, device, _keyGuid, _mobilePasscode, DateTime.Now, DateTime.Now, true);
                }
                else
                {
                    if (checkDb.First().MobilePasscode != null)
                    {
                        _mobilePasscode = new Guid(checkDb.First().MobilePasscode.ToString());
                    }
                }

                return(true);
            }
            else
            {
                _keyGuid        = Guid.Empty;
                _mobilePasscode = Guid.Empty;
                return(false);
            }
        }
コード例 #2
0
ファイル: KeyUser.cs プロジェクト: mailekah/AgapeConnect1
        private static void StoreKeyCredentials(AP_KeyCredentials keyCred)
        {
            KeyEntities acEntity = new KeyEntities();

            try
            {
                acEntity.AddToAP_KeyCredentials(keyCred);
                acEntity.SaveChanges();
            }
            catch (Exception e)
            {
            }
        }
コード例 #3
0
ファイル: KeyUser.cs プロジェクト: mailekah/AgapeConnect1
        private bool GetKeyCredentials(Guid keyGuid, Guid mobilePasscode)
        {
            //Using ssocode and mobilepasscode, get username and password

            var e = new KeyEntities().AP_KeyCredentials.Where(k => ((k.KeyGuid == keyGuid) && (k.MobilePasscode == mobilePasscode)));

            if (e.Count <AP_KeyCredentials>() > 0)
            {
                //If found, set the values
                if (!string.IsNullOrEmpty(e.First <AP_KeyCredentials>().Username))
                {
                    _username = ADCEncrypt.Decrypt(e.First <AP_KeyCredentials>().Username);
                }
                else
                {
                    _username = string.Empty;
                }

                if (!string.IsNullOrEmpty(e.First <AP_KeyCredentials>().Password))
                {
                    _password = ADCEncrypt.Decrypt(e.First <AP_KeyCredentials>().Password);
                }
                else
                {
                    _username = string.Empty;
                }

                _device = e.First <AP_KeyCredentials>().Device;

                return(true);
            }
            else
            {
                //if not found, return false
                _username = string.Empty;
                _password = string.Empty;
                return(true);
            }
        }