Ejemplo n.º 1
0
        public async Task <IActionResult> Login([FromBody] LoginViewModel viewModel)
        {
            LoginResultViewModel result = new LoginResultViewModel();

            UserDto user = await _userAccountService.Login(viewModel.Email, viewModel.Password);

            if (user != null)
            {
                var claims = new List <Claim>
                {
                    new Claim(ClaimTypes.Name, viewModel.Email),
                    new Claim(ClaimTypes.Role, "User"),
                };

                var claimsIdentity = new ClaimsIdentity(
                    claims, CookieAuthenticationDefaults.AuthenticationScheme);
                var authProperties = new AuthenticationProperties();

                result = PrepareUserViemModel(user, claims);

                await HttpContext.SignInAsync(
                    CookieAuthenticationDefaults.AuthenticationScheme,
                    new ClaimsPrincipal(claimsIdentity),
                    authProperties);

                return(Json(result));
            }

            result.Email    = viewModel.Email;
            result.IsLogged = false;


            return(Json(result));
        }
Ejemplo n.º 2
0
        public async Task <LoginResultViewModel> Login([FromBody] LoginViewModel model)
        {
            var response = new LoginResultViewModel();

            if (ModelState.IsValid)
            {
                var result = await _signInManager.PasswordSignInAsync(model.Username, model.Password, model.RememberMe, lockoutOnFailure : false);

                if (result.Succeeded)
                {
                    _logger.LogInformation("User logged in.");

                    var user = await _userManager.FindByNameAsync(model.Username);

                    response.Username    = user.UserName;
                    response.DisplayName = user.DisplayName;
                    response.Email       = user.Email;
                    response.Succeeded   = true;
                }
                else
                {
                    response.Succeeded = false;
                }
            }
            return(response);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> LoginAsync([FromBody] LoginViewModel model)
        {
            var user = context.Users.SingleOrDefault(u => u.UserName == model.UserName);

            if (user == null)
            {
                ModelState.AddModelError("", "Não existe usuário com o email especificado.");
            }

            if (user != null)
            {
                var signInResult = await signInManager.PasswordSignInAsync(user, model.Password, false, false);

                if (signInResult.Succeeded)
                {
                    var result = new LoginResultViewModel
                    {
                        Login = user.UserName,
                        Token = await GetToken(user),
                    };
                    return(Ok(result));
                }
                else
                {
                    ModelState.AddModelError("", "Usuário ou Senha inválidos");
                }
            }

            return(BadRequest(ModelState));
        }
Ejemplo n.º 4
0
        private async Task LoginAsync()
        {
            LoginInternet loginObj = new LoginInternet();

            LoginResult.Type resultType;
            ChallengeReq     challengeReq = new ChallengeReq(Text_Account.Text);

            var result = await loginObj.ChallengeAsync(challengeReq);

            if (string.IsNullOrEmpty(result))
            {
                resultType = LoginResult.Type.CodeError;
            }

            LoginReq loginReq = new LoginReq(challengeReq, Text_Password.Password, result);

            resultType = await loginObj.LoginAsync(loginReq);

            // loginResult

            LoginResultViewModel viewModel = LoginResultViewModel.GetInstance();

            viewModel.LoginInfo = new LoginResult(resultType).ReusltInfo;

            //keepActTimer.Start();

            // 自动保存账号
            if (AppSettings.Default.autoSave)
            {
                AppSettings.Default.account  = Text_Account.Text;
                AppSettings.Default.password = Text_Password.Password;
                AppSettings.Default.Save();
            }
        }
Ejemplo n.º 5
0
        public async Task <ActionResult <LoginResultViewModel> > Register([FromBody] RegisterViewModel request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Wrong request"));
            }
            // Check if account with same public address already exits.

            // Verification succeeded, create new user, change nonce and return JWT
            try
            {
                string userId = await accountService.CreateUser(request);

                List <string> roles = await accountService.GetUserRoles(userId);

                string jwt = authService.GenerateToken(userId, roles.ToList());
                LoginResultViewModel loginResult = new LoginResultViewModel()
                {
                    Jwt           = jwt,
                    Id            = userId,
                    FullName      = request.FullName,
                    PublicAddress = request.PublicAddress,
                    Role          = roles.LastOrDefault()
                };
                return(Ok(loginResult));
            }
            catch (DataSaveException e)
            {
                return(Unauthorized(e.Message));
            }
        }
Ejemplo n.º 6
0
        private void SetLoggedInUserMessages(LoginResultViewModel viewModel)
        {
            var message = "";

            if (viewModel.PendingUsernameVerificationRequired)
            {
                message += string.Format(LoginPageMessages.PendingUsernameVerificationRequiredText,
                                         Url.RouteUrl(RouteNames.VerifyUpdatedEmail));

                SetUserMessage(message, UserMessageLevel.Info);
            }

            if (viewModel.MobileVerificationRequired)
            {
                if (!string.IsNullOrEmpty(message))
                {
                    message += "<br/><br/>";
                }

                message += string.Format(LoginPageMessages.MobileVerificationRequiredText, viewModel.PhoneNumber,
                                         Url.RouteUrl(CandidateRouteNames.VerifyMobile,
                                                      new RouteValueDictionary
                {
                    {
                        "ReturnUrl", viewModel.ReturnUrl
                    }
                }));

                SetUserMessage(message, UserMessageLevel.Info);
            }
        }
Ejemplo n.º 7
0
        public LoginResultViewModel Login(LoginViewModel loginViewModel)
        {
            var result = new LoginResultViewModel();
            var entity = _usersRepository.Login(loginViewModel.Identifier, loginViewModel.Credential.ToMd5());

            result.Identifier = loginViewModel.Identifier;
            result.User       = _mapper.Map <UsersViewModel>(entity);
            if (entity == null)
            {
                result.LoginSuccess = false;
                result.Message      = "Account or password wrong ";
                result.Result       = LoginResult.AccountOrPasswordWrong;
            }
            else
            {
                result.LoginSuccess = true;
            }
            var loginLog = new LoginLogs
            {
                UserId    = entity?.Id,
                LoginName = entity.Name,
                IP        = loginViewModel.IP,
                LoginTime = DateTime.Now,
                Message   = result.Message
            };

            //增加日志
            return(result);
        }
        public LoginResultViewModel Login(LoginViewModel login)
        {
            LoginResultViewModel loginResult = new LoginResultViewModel();
            var user = (from u in _dbContext.Users
                        where u.PhoneNumber == login.Phone
                        select u).FirstOrDefault();

            if (user != null)
            {
                if (user.PhoneNumberConfirmed == true)
                {
                    if (user.Password == null)
                    {
                        loginResult.Message = "fail";
                        return(loginResult);
                    }
                    else if (Classes.SimpleHash.VerifyHash(login.Password, "sha256", user.Password))
                    {
                        loginResult.Id   = user.Id;
                        loginResult.Role = user.Role;

                        if (user.FullName == "" || user.FullName == null)
                        {
                            loginResult.FullName = "نام و نام خانوادگی";
                        }
                        else
                        {
                            loginResult.FullName = user.FullName;
                        }
                        if (user.Avatar == null)
                        {
                            loginResult.Avatar = "/dist/img/avatar5.png";
                        }
                        else
                        {
                            loginResult.Avatar = "/uploads/" + user.Id + "/" + user.Avatar;
                        }

                        loginResult.Message = "success";
                        return(loginResult);
                    }
                    else
                    {
                        loginResult.Message = "fail";
                        return(loginResult);
                    }
                }
                else
                {
                    loginResult.Message = "confirm";
                    return(loginResult);
                }
            }
            else
            {
                loginResult.Message = "notexist";
                return(loginResult);
            }
        }
Ejemplo n.º 9
0
        public LoginResultViewModel ReturnLoginResult(bool isSuccess, string token)
        {
            LoginResultViewModel login = new LoginResultViewModel();

            login.Token     = token;
            login.IsSuccess = isSuccess;

            return(login);
        }
Ejemplo n.º 10
0
        public ActivateViewModel PostActivate(ActivateInputViewModel input)
        {
            try
            {
                string tokenId        = input.TokenId;
                string activationCode = input.ActivationCode;
                string deviceId       = input.DeviceId;
                string deviceModel    = input.DeviceModel;
                string osType         = input.OsType;
                string osVersion      = input.OsVersion;


                ActivateViewModel activate = new ActivateViewModel();
                Status            status   = new Status();
                ActivateResult    result   = new ActivateResult();

                ActivationCode activation = IsValidActivationCode(tokenId, activationCode);
                if (activation != null)
                {
                    User user = ActivateUser(tokenId, activationCode);
                    UpdateActivationCode(activation, deviceId, deviceModel, osType, osVersion);
                    UnitOfWork.Save();

                    status.IsSuccess  = true;
                    status.Message    = Resources.Messages.Register_SuccessActivate;
                    status.StatusCode = 0;

                    LoginResultViewModel login = Login(user.CellNum, user.Password);
                    if (login.IsSuccess)
                    {
                        UpdateUserWithToken(user, login.Token);
                        result.TokenId = login.Token;
                        UnitOfWork.Save();
                    }
                }
                else
                {
                    status.IsSuccess  = false;
                    status.Message    = Resources.Messages.Registe_WrongActivationCode;
                    status.StatusCode = 2;
                }

                activate.Result = result;
                activate.Status = status;
                return(activate);
            }
            catch (Exception e)
            {
                return(new ActivateViewModel()
                {
                    Result = null,
                    Status = status.ReturnStatus(100, "خطا در بازیابی اطلاعات", false)
                });
            }
        }
Ejemplo n.º 11
0
        public ActionResult <LoginResultViewModel> Login([FromBody] UserViewModel model)
        {
            var result      = new LoginResultViewModel();
            var loginResult = _authRepository.Login(new User
            {
                Email    = model.Email,
                Password = model.Password
            });

            result.IsLogin = loginResult.IsLogin;

            if (result.IsLogin)
            {
                result.User = new UserViewModel
                {
                    Email       = loginResult.User.Email,
                    Id          = loginResult.User.Id,
                    DisplayName = loginResult.User.DisplayName,
                    IsAdmin     = loginResult.User.IsAdmin,
                    TotalScore  = loginResult.User.TotalScore,
                };

                if (loginResult.User.DefaultBaseLanguage != null)
                {
                    result.User.DefaultBaseLanguage = new LanguageViewModel
                    {
                        Id         = loginResult.User.DefaultBaseLanguage.Id,
                        Code       = loginResult.User.DefaultBaseLanguage.Code,
                        FullName   = loginResult.User.DefaultTargetLanguage.FullName,
                        Name       = loginResult.User.DefaultBaseLanguage.Name,
                        NativeName = loginResult.User.DefaultBaseLanguage.NativeName,
                    };
                }
                if (loginResult.User.DefaultTargetLanguage != null)
                {
                    result.User.DefaultTargetLanguage = new LanguageViewModel
                    {
                        Id         = loginResult.User.DefaultTargetLanguage.Id,
                        Code       = loginResult.User.DefaultTargetLanguage.Code,
                        FullName   = loginResult.User.DefaultTargetLanguage.FullName,
                        Name       = loginResult.User.DefaultTargetLanguage.Name,
                        NativeName = loginResult.User.DefaultTargetLanguage.NativeName,
                    };
                }
                result.Token = _authRepository.GenerateToken(loginResult.User);
            }
            else
            {
                result.Message = loginResult.Message;
            }

            return(Ok(result));
        }
Ejemplo n.º 12
0
        private LoginResultViewModel PrepareUserViemModel(UserDto user, List <Claim> claims)
        {
            LoginResultViewModel result = _mapper.Map <LoginResultViewModel>(user);

            result.IsLogged = true;
            if (user.IsAdmin)
            {
                result.Roles.Add("Admin");
                claims.Add(new Claim(ClaimTypes.Role, "Admin"));
            }
            result.Roles.Add("User");
            return(result);
        }
Ejemplo n.º 13
0
        public LoginResultViewModel Build()
        {
            var viewModel = new LoginResultViewModel
            {
                UserStatus       = _userStatus,
                IsAuthenticated  = _isAuthenticated,
                EmailAddress     = _emailAddress,
                ViewModelMessage = _viewModelMessage,
                AcceptedTermsAndConditionsVersion = _acceptedTermsAndConditionsVersion,
                MobileVerificationRequired        = _mobileVerificationRequired
            };

            return(viewModel);
        }
Ejemplo n.º 14
0
        public ActionResult Login(LoginViewModel model)
        {
            ViewBag.Kamlesh = "My Name is Kamlesh";
            ViewBag.Bikram  = "My Name is Bikram";
            ViewBag.Saroj   = "My Name is Saroj";

            ViewData["Chandan"] = "My Name is Chandan";
            var result = new LoginResultViewModel();

            result.Message  = "You have successfully logged in";
            result.Username = model.Username;

            return(View(result));
        }
Ejemplo n.º 15
0
        public LoginViewModel PostLogin(LoginInputViewModel input)
        {
            string cellNumber     = input.CellNumber;
            string password       = input.Password;
            Guid   employeeRoleId = new Guid("6d352c2f-6e64-4762-aae4-00f49979d7f1");
            Guid   employerRoleId = new Guid("b999eb27-7330-4062-b81f-62b3d1935885");

            LoginViewModel login  = new LoginViewModel();
            Status         status = new Status();
            LoginResult    result = new LoginResult();

            User user = UnitOfWork.UserRepository
                        .Get(current => current.CellNum == cellNumber && current.Password == password &&
                             (current.RoleId == employerRoleId || current.RoleId == employeeRoleId))
                        .FirstOrDefault();

            if (user != null)
            {
                LoginResultViewModel loginResult = Login(cellNumber, password);
                if (loginResult.IsSuccess)
                {
                    UpdateUserWithToken(user, loginResult.Token);
                    UnitOfWork.Save();

                    result.TokenId = loginResult.Token;

                    status.StatusCode = 0;
                    status.IsSuccess  = true;
                    status.Message    = Resources.Messages.Login_SuccessLogin;
                }
                else
                {
                    result.TokenId    = loginResult.Token;
                    status.StatusCode = 20;
                    status.IsSuccess  = false;
                    status.Message    = Resources.Messages.Login_BadRequest;
                }
            }
            else
            {
                result            = null;
                status.StatusCode = 11;
                status.IsSuccess  = false;
                status.Message    = Resources.Messages.Login_BadRequest;
            }
            login.Result = result;
            login.Status = status;
            return(login);
        }
        public async Task <IActionResult> Loggin(UserViewModel userVM)
        {
            var user = await _unitOfWork.UserRepository.Authenticate(userVM.UserName, userVM.Password);

            if (user == null)
            {
                return(Unauthorized("Invalid User Id or Password"));
            }
            var loginResponse = new LoginResultViewModel();

            loginResponse.UserName = user.UserName;
            loginResponse.Role     = user.Role;
            loginResponse.Token    = CreateJwt(user);
            return(Ok(loginResponse));
        }
Ejemplo n.º 17
0
        public async Task <ActionResult <LoginResultViewModel> > Login([FromBody] LoginViewModel request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("wrong request"));
            }
            // Get the user with the given publicAddress
            UserDataViewModel user = accountService.GetUserWithPublicAddress(request.PublicAddress);

            if (user is null)
            {
                return(Unauthorized("User not found."));
            }
            // Verify digital signature
            string message = "I am signing my one-time nonce: " + accountService.GetNonce(request.PublicAddress).ToString();
            string result  = authService.VerifyMessage(message, request.Signature, request.PublicAddress);

            if (String.IsNullOrEmpty(result))
            {
                return(Unauthorized("Signature verification failed!"));
            }
            // Verification succeeded, check if account is lockout
            if (!user.IsActive)
            {
                return(BadRequest("account is lockout"));
            }

            // Verification succeeded, create new user, change nonce and return JWT
            long nonce = await accountService.ChangeNonce(user.PublicAddress);

            List <string> roles = await accountService.GetUserRoles(user.Id.ToString());

            string jwt = authService.GenerateToken(result, roles.ToList());
            LoginResultViewModel loginResult = new LoginResultViewModel()
            {
                Jwt           = jwt,
                Id            = user.Id,
                FullName      = user.FullName,
                PublicAddress = user.PublicAddress,
                Role          = roles.LastOrDefault()
            };

            return(Ok(loginResult));
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 用户注册
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <LoginResultViewModel> RegisterAsync(User model)
        {
            var AuthResult = new LoginResultViewModel();

            AuthResult.IsSuccess = false;

            var db = base.CreateDb <User>();

            db.Add(model);

            var row = await db.SaveChangesAsync();

            if (row > 0)
            {
                AuthResult.IsSuccess = true;
            }

            return(AuthResult);
        }
Ejemplo n.º 19
0
        //登陆
        public async Task <LoginResultViewModel> UserLoginAsync(string userName, string passWord)
        {
            var AuthResult = new LoginResultViewModel();

            AuthResult.IsSuccess = false;
            var db = base.CreateDb <User>();

            try
            {
                var user = await db.Query().Where(t => t.isDeleted == false && t.UserName == userName)
                           .Include(t => t.UserRoles.Select(p => p.Role)).FirstOrDefaultAsync();

                if (user == null)
                {
                    AuthResult.MessageResult = "不存在该用户!";
                    return(AuthResult);
                }

                if (user.PassWord != passWord)
                {
                    AuthResult.MessageResult = "密码错误!";
                }
                else
                {
                    AuthResult.IsSuccess = true;
                    AuthResult.UserId    = user.Id;//登录成功,返回该用户的id

                    var roles = user.UserRoles.FirstOrDefault();
                    if (roles != null)
                    {
                        var userType = this.GetUserType(roles.Role);//获取用户类型枚举
                        AuthResult.UserType = userType;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }


            return(AuthResult);
        }
Ejemplo n.º 20
0
        public async Task <IActionResult> Login([FromBody] LoginInfo loginInfo)
        {
            var user = await _context.Users.FirstOrDefaultAsync(u => u.Account == loginInfo.Account.Trim());

            if (user == null)
            {
                return(BadRequest("账号不存在"));
            }

            if (user.Password != loginInfo.Password)
            {
                return(BadRequest("账号或密码错误"));
            }

            if (user.Status != 0)
            {
                return(BadRequest("账号状态异常"));
            }

            var data = new LoginResultViewModel
            {
                Avatar = user.Avatar ?? string.Empty,
                Id     = user.Id,
                NiName = user.NiName ?? string.Empty,
            };

            var exp    = $"{new DateTimeOffset(DateTime.Now.AddMinutes(_settings.ExpMinutes)).ToUnixTimeSeconds()}";
            var claims = new List <Claim>
            {
                new Claim(JwtRegisteredClaimNames.Jti, user.Id.ToString()),
                new Claim("niName", user.NiName ?? string.Empty),
                new Claim("avatar", user.Avatar ?? string.Empty),
                new Claim(JwtRegisteredClaimNames.Iss, _settings.Issuer),
                new Claim(JwtRegisteredClaimNames.Aud, _settings.Audience),
                new Claim(JwtRegisteredClaimNames.Exp, exp),
            };

            // 生成token
            var token = JwtBearerAuthenticationExtension.GetJwtAccessToken(_settings, claims);

            data.Token = token;
            return(Ok(data));
        }
        public async Task <IActionResult> Login([FromBody] LoginViewModel loginInfo)
        {
            var user = await _userRepo.FindAsync(q => q.UserName == loginInfo.UserName);

            if (user == null)
            {
                return(BadRequest("invalid username & password"));
            }

            var hashPassword = EncyrptionUtility.GenerateHashWithSalt(loginInfo.Password, user.PasswordSalt);

            if (user.Password != hashPassword)
            {
                return(BadRequest("invalid username & password"));
            }

            var refreshToken = GenerateNewRefreshToken();
            //step 1 : invalid user refresh token
            //step 2 : insert new refreshtoken in db
            var userToken = new UserTokens
            {
                CreateDate   = DateTime.Now,
                ExpireDate   = DateTime.Now.AddMinutes(_tokenTimeOut),
                IsValid      = true,
                RefreshToken = refreshToken,
                UserId       = user.Id
            };
            await _userTokenRepo.AddAsync(userToken);

            var model = new LoginResultViewModel
            {
                UserId       = user.Id,
                FirstName    = user.UserName,
                LastName     = "Rezaei",
                Token        = GenerateNewToken(user.Id.ToString()),
                RefreshToken = refreshToken
            };

            return(Ok(model));
        }
Ejemplo n.º 22
0
        public async Task <ActionResult <LoginResultViewModel> > Login(LoginInputModel inputModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Account account = await _identityService.LoginUserAsync(inputModel.Username, inputModel.Password);

            if (account == null)
            {
                return(BadRequest("Invalid credentials"));
            }

            var result = new LoginResultViewModel()
            {
                UserId   = account.User.Id,
                Username = account.Username
            };

            return(result);
        }
Ejemplo n.º 23
0
        private void SetToken(LoginResultViewModel loginResultViewModel)
        {
            if (loginResultViewModel == null)
            {
                return;
            }

            loginResultViewModel.TokenExpirationDate = DateTime.Now.AddHours(EnvironmentVariableValues.TokenLifetime);

            var tokenHandler    = new JwtSecurityTokenHandler();
            var key             = Encoding.UTF8.GetBytes(EnvironmentVariableValues.AppSecret);
            var tokenDescriptor = new SecurityTokenDescriptor
            {
                Subject = new ClaimsIdentity(new Claim[]
                {
                    new Claim(ClaimTypes.Name, loginResultViewModel.Id.ToString())
                }),
                Expires            = loginResultViewModel.TokenExpirationDate,
                SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature)
            };
            var token = tokenHandler.CreateToken(tokenDescriptor);

            loginResultViewModel.Token = tokenHandler.WriteToken(token);
        }
Ejemplo n.º 24
0
        public async Task <LoginResultViewModel> LoginAsync(
            LoginViewModel login,
            UserManager <Models.User> userManager,
            SignInManager <Models.User> signInManager)
        {
            LoginResultViewModel loginResult = new LoginResultViewModel();
            //var user = (from u in _dbContext.Users
            //            where u.PhoneNumber == login.Phone
            //            select u).FirstOrDefault();

            //var user = (from u in userManager.Users
            //            where u.PhoneNumber == login.Email
            //            select u).FirstOrDefault();
            var user = await userManager.FindByEmailAsync(login.EmailOrUsername);

            if (user == null)
            {
                user = await userManager.FindByNameAsync(login.EmailOrUsername);
            }

            if (user != null)
            {
                loginResult.Id    = user.Id;
                loginResult.Email = user.Email;

                if (user.EmailConfirmed)
                {
                    //if (user.PasswordHash == null)
                    //{
                    //    loginResult.Message = "fail";
                    //    return loginResult;
                    //}
                    if ((await signInManager.PasswordSignInAsync(user, login.Password, false, false)).Succeeded)
                    //else if (Classes.SimpleHash.VerifyHash(login.Password, "sha256", user.PasswordHash))
                    {
                        //loginResult.Role = (await userManager.GetRolesAsync(user)).First() ?? "";
                        //loginResult.Role = user.Role;

                        //if (user.FullName == "" || user.FullName == null)
                        //    loginResult.FullName = "نام و نام خانوادگی";
                        //else
                        //    loginResult.FullName = user.FullName;
                        //if (user.Avatar == null)
                        //{
                        //    loginResult.Avatar = "/dist/img/avatar5.png";
                        //}
                        //else
                        //{
                        //    loginResult.Avatar = "/uploads/" + user.Id + "/" + user.Avatar;
                        //}

                        loginResult.Message = "success";
                        return(loginResult);
                    }
                    else
                    {
                        loginResult.Message = "fail";
                        return(loginResult);
                    }
                }
                else
                {
                    if (!(await signInManager.PasswordSignInAsync(user, login.Password, false, false)).Succeeded)
                    {
                        loginResult.Message = "fail";
                        return(loginResult);
                    }
                    else
                    {
                        loginResult.Message = "verify";
                        return(loginResult);
                    }
                }
            }
            else
            {
                loginResult.Message = "notexist";
                return(loginResult);
            }
        }
Ejemplo n.º 25
0
 public Settings()
 {
     BindingContext = new LoginResultViewModel();
     InitializeComponent();
 }
Ejemplo n.º 26
0
        public Menu()
        {
            BindingContext = new LoginResultViewModel();
            InitializeComponent();

            if (AppSettings.Logged && !AppSettings.LoggedAsGuest)
            {
                masterPageItems = new List <MasterPageItem>
                {
                    new MasterPageItem
                    {
                        Title      = "Главная",
                        Icon       = "home.png",
                        TargetType = typeof(Views.Main)
                    },
                    new MasterPageItem
                    {
                        Title      = "История",
                        Icon       = "history.png",
                        TargetType = typeof(Views.History)
                    },
                    new MasterPageItem
                    {
                        Title      = "Избранное",
                        Icon       = "favorites.png",
                        TargetType = typeof(Views.Favorites)
                    },
                    new MasterPageItem
                    {
                        Title      = "Акции",
                        Icon       = "sale.png",
                        TargetType = typeof(Views.Shares)
                    },
                    new MasterPageItem
                    {
                        Title      = "Настройки",
                        Icon       = "settings.png",
                        TargetType = typeof(Views.Settings)
                    },
                    new MasterPageItem
                    {
                        Title      = "О нас",
                        Icon       = "about.png",
                        TargetType = typeof(Views.About)
                    }
                };
            }
            if (AppSettings.LoggedAsGuest)
            {
                masterPageItems = new List <MasterPageItem>
                {
                    new MasterPageItem
                    {
                        Title      = "Главная",
                        Icon       = "home.png",
                        TargetType = typeof(Views.Main)
                    },
                    new MasterPageItem
                    {
                        Title      = "Акции",
                        Icon       = "sale.png",
                        TargetType = typeof(Views.Shares)
                    },
                    new MasterPageItem
                    {
                        Title      = "О нас",
                        Icon       = "about.png",
                        TargetType = typeof(Views.About)
                    }
                };
            }
            menuList.ItemsSource = masterPageItems;


            //UserData userData = new UserData()
            //{
            //    Name = "Name",
            //    Surname = "Surname",
            //    Points = "999"
            //};
            //BindingContext = userData;
            //LoginResult userData = new LoginResult()
            //{
            //};
            //BindingContext = userData;
        }