示例#1
0
        private ClaimsIdentity GetIdentity(string username, string password)
        {
            var users = DBCarServiceDL_ADMIN.SearchAdmin(username);

            if (users != null)
            {
                if (users.password != GetCode.Hash(password))
                {
                    return(null);
                }

                else
                {
                    var claims = new List <Claim>
                    {
                        new Claim(ClaimsIdentity.DefaultNameClaimType, users.login),
                        new Claim(ClaimsIdentity.DefaultRoleClaimType, users.role)
                    };

                    ClaimsIdentity claimsIdentity =
                        new ClaimsIdentity(claims, "Token",
                                           ClaimsIdentity.DefaultNameClaimType,
                                           ClaimsIdentity.DefaultRoleClaimType);

                    return(claimsIdentity);
                }
            }
            return(null);
        }
示例#2
0
        private static void Main(string[] args)
        {
            GetCode getCode = new GetCode();

            CodeAppUsers(getCode);

            getCode.Run("output.txt");
        }
        private void Getcode_Click(object sender, EventArgs e)
        {
            if (!switcher)  //for GETCODE button
            {
                if (checkValidPhoneNumber(getphone.Text))
                {
                    changeType(); //change state of the BUTTON
                    code = connector.GetData <GetCode>(APIConnection.CodeByTelephone, phone);
                }
            }
            else //for CONFIRM button
            {
                int compare = code.Expiration_time.CompareTo(DateTime.Now); //get TIME NOW
                if (compare >= 0) //input confirm code ontime
                {
                    confirm = getphone.Text;
                    if (confirm == code.Verified_code)//correct
                    {
                        check = connector.GetData <checkTelephone>(APIConnection.UserByTelephone, phone);
                        if (check.IsNew) //newbie
                        {
                            Intent initial3 = new Intent(this, typeof(initial3Activity));
                            initial3.PutExtra("user_id", check.User_id);
                            StartActivity(initial3);
                        }
                        else //pro
                        {
                            //Bundle bunlde = new Bundle();
                            //bunlde.PutString("user_id", check.User_id);
                            //HomeFragment home = new HomeFragment();
                            //home.Arguments = bunlde;

                            Intent mainActivity = new Intent(this, typeof(MainActivity));
                            mainActivity.PutExtra("user_id", check.User_id);
                            StartActivity(mainActivity);
                        }
                        editor.PutString("user_id", check.User_id);
                        editor.Apply();
                    }
                    else
                    {
                        alertMes("Sorry", "You have input an incorrect code. Try again!", "OK");
                    }
                }
                else
                {
                    alertMes("Sorry", "The code is expired. You will received another one!", "OK");
                    code = connector.GetData <GetCode>(APIConnection.CodeByTelephone, getphone.Text);
                }
            }
        }
        private ObservableCollection <ColorInfo> Load_Colors()
        {
            var        result     = new ObservableCollection <ColorInfo>();
            EntryCodes entryCodes = new EntryCodes();

            foreach (var meaning in Enum.GetValues(entryCodes.GetType()))
            {
                result.Add(new ColorInfo
                {
                    Mean = GetCode.GetCodeMeaning((EntryCodes)meaning),
                    Name = GetColor.GetColorByCode((EntryCodes)meaning).Name
                });
            }
            return(result);
        }
示例#5
0
        private List <EntryModel> JoinSameEntries()
        {
            List <EntryModel> newModels = new List <EntryModel>(_entryModels.Count);
            List <EntryModel> entries   = new List <EntryModel>(_entryModels.Count);

            for (int i = 0; i < _entryModels.Count; i++)
            {
                EntryModel currentModel = _entryModels[i];
                for (int j = i + 1; j < _entryModels.Count; j++)
                {
                    if (_entryModels[i].StartIndex == _entryModels[j].StartIndex)
                    {
                        entries.Add(_entryModels[j]);
                    }
                    else
                    {
                        break;
                    }
                }
                if (entries.Count > 0)
                {
                    int r = currentModel.TextColor.R,
                        g = currentModel.TextColor.G,
                        b = currentModel.TextColor.B;
                    StringBuilder newMeaning = new StringBuilder(GetCode.GetCodeMeaning(GetCode.GetCodeByColor(currentModel.TextColor)));
                    foreach (var entry in entries)
                    {
                        newMeaning.Append($", {GetCode.GetCodeMeaning(GetCode.GetCodeByColor(entry.TextColor))}");
                        r += entry.TextColor.R;
                        g += entry.TextColor.G;
                        b += entry.TextColor.B;
                    }
                    r %= 255;
                    g %= 255;
                    b %= 255;
                    currentModel.TextColor = Color.FromArgb(r, g, b);
                    NewColorCreated?.Invoke(currentModel.TextColor, newMeaning.ToString());
                    i += entries.Count;
                }
                newModels.Add(currentModel);
                entries.Clear();
            }
            return(newModels);
        }
示例#6
0
        private static void CodeAppUsers(GetCode getCode)
        {
            CodeModel myCodeModel = getCode.MyCodeModel;

            myCodeModel.ModuleName  = "AppUser";
            myCodeModel.ContextName = "AppUsers";
            myCodeModel.ClassName   = "AppUser";

            myCodeModel.Fields.Add(new FieldModel()
            {
                FieldName = "Id",
                IsString  = true
            });

            myCodeModel.Fields.Add(new FieldModel()
            {
                FieldName = "Email",
                IsString  = true,
                IsInput   = true,
            });

            myCodeModel.Fields.Add(new FieldModel()
            {
                FieldName = "EmailConfirmed",
                IsBool    = true,
                IsInput   = true,
            });

            myCodeModel.Fields.Add(new FieldModel()
            {
                FieldName = "PhoneNumber",
                IsString  = true,
                IsInput   = true,
            });

            myCodeModel.Fields.Add(new FieldModel()
            {
                FieldName = "UserName",
                IsString  = true,
                IsInput   = true,
            });
        }
示例#7
0
        public async Task <IHttpActionResult> CheckValidCode(GetCode Code)
        {
            try
            {
                ValidCode validCode = await db.ValidCodes
                                      .Where(x => x.Code == Code.Code)
                                      .FirstOrDefaultAsync();

                if (validCode == null)
                {
                    return(NotFound());
                }

                return(Ok(validCode));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
示例#8
0
        public JsonResult Post([FromBody] JObject value)
        {
            AdminModel candidate = new AdminModel()
            {
                login    = value["login"].ToString(),
                password = GetCode.Hash(value["password"].ToString()),
                role     = value["role"].ToString()
            };

            var result = DBCarServiceDL_ADMIN.SearchAdmin(candidate.login);

            if (result == null)
            {
                var temp = DBCarServiceDL_ADMIN.AdminADD(candidate);
                if (temp > 0)
                {
                    return(new JsonResult(new ResponsModel()
                    {
                        status = true
                    }));
                }
                else
                {
                    return(new JsonResult(new ResponsModel()
                    {
                        status = false, description = "registration failed"
                    }));
                }
            }
            else
            {
                return(new JsonResult(new ResponsModel()
                {
                    status = false, description = "already exists"
                }));
            }
        }