Exemplo n.º 1
0
        public static string GenerateJwtTokens(this Data.Users user)
        {
            var claims = new[]
            {
                new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString("N")),


                new Claim(ClaimsIdentity.DefaultNameClaimType, user.UserName),

                new Claim(ClaimTypes.NameIdentifier, user.Id)
            };

            //Crear Credenciales Usadas para generar el token

            var credentials = new SigningCredentials(
                new SymmetricSecurityKey(Encoding.UTF8.GetBytes(configurations[2])), SecurityAlgorithms.HmacSha256);

            //Generar el JsonWebToken

            var token = new JwtSecurityToken(

                issuer: configurations[0],
                audience: configurations[1],
                claims: claims,
                expires: DateTime.Now.AddHours(6),
                signingCredentials: credentials);

            var response = new JwtSecurityTokenHandler().WriteToken(token);


            return(response);
        }
Exemplo n.º 2
0
        public ActionResult EditMyInfo(FormCollection fc)
        {
            var model = new Data.Users();

            model.ID          = umodel.ID;
            model.Names       = fc["Names"];
            model.Phone       = fc["Phone"];
            model.Sex         = TypeConverter.StrToInt(fc["Sex"]);
            model.EMail       = fc["EMail"];
            model.QQ          = fc["QQ"];
            model.CompanyName = fc["CompanyName"];

            string _starttime = DateTime.Now.ToString("yyyy-MM-dd");

            _starttime      = _starttime + " " + fc["StartTime1"] + ":" + fc["StartTime2"] + ":00";
            model.StartTime = TypeConverter.StrToDateTime(_starttime);

            string _endtime = DateTime.Now.ToString("yyyy-MM-dd");

            _endtime      = _endtime + " " + fc["EndTime1"] + ":" + fc["EndTime2"] + ":00";
            model.EndTime = TypeConverter.StrToDateTime(_endtime);



            var flag = Data.UsersDB.SaveEditUsersMyInfo(model);

            return(Json(new { success = flag }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
 public Access.Users GetByUserTypeID(Int32 UserThemeID)
 {
     Data.Users DataUsers = new Data.Users();
     DataUsers.GetByUserThemeID(UserThemeID);
     Generate(DataUsers);
     return(this);
 }
Exemplo n.º 4
0
 public static EndUser Map(Data.Users user) => new EndUser
 {
     UserID        = user.UserId,
     FirstName     = user.FirstName,
     LastName      = user.LastName,
     StoreLocation = user.StorePref,
     OrderPref     = user.OrderPref
 };
 public static UserModel Map(Data.Users usuario) => new UserModel
 {
     Id                = usuario.Id,
     FirstName         = usuario.FirstName,
     LastName          = usuario.LastName,
     DefaultLocationFk = usuario.DefaultLocationFk,
     PhoneNumber       = usuario.PhoneNumber
 };
Exemplo n.º 6
0
 protected override void Initialize(System.Web.Routing.RequestContext requestContext)
 {
     base.Initialize(requestContext);
     if (TheCMS.Common.Cookie.GetCookie("UserID") != null && TheCMS.Common.Cookie.GetCookie("UserID").ToString() != "")
     {
         var userID = TypeConverter.StrToInt(TheCMS.Common.Cookie.GetCookie("UserID").ToString());
         umodel = Data.UsersDB.GETUsers(userID);
     }
 }
Exemplo n.º 7
0
 public static User Map(Data.Users otherUser) => new User
 {
     Username     = otherUser.Username,
     FirstName    = otherUser.FirstName,
     LastName     = otherUser.LastName,
     Email        = otherUser.Email,
     Phone        = otherUser.Phone,
     FavStore     = otherUser.FavLocation,
     OrderHistory = Map(otherUser.Orders).Select(m => m.Id).ToList()
 };
Exemplo n.º 8
0
        /// <summary>
        /// ham tra ve thong tin so luong dang nhap CS trong vung
        /// </summary>
        public static int GetSoLuongCSDangNhapThuocVung(string Vung)
        {
            List <string> lstDSMayCSDangDangNhap = new Data.Users().GetDSMayCSDangNhapThuocVung(Vung);

            if (lstDSMayCSDangDangNhap != null)
            {
                return(lstDSMayCSDangDangNhap.Count);
            }
            return(0);
        }
Exemplo n.º 9
0
        public ActionResult RegisterFast(FormCollection fc)
        {
            var model = new Data.Users();

            model.Address    = fc["hidSAddress"];
            model.EndAddress = fc["hidEAddress"];

            model.StartLat  = TypeConverter.StrToDouble(fc["hidSLat"], 0);
            model.StartLong = TypeConverter.StrToDouble(fc["hidSLong"], 0);
            model.EndLat    = TypeConverter.StrToDouble(fc["hidELat"], 0);
            model.EndLong   = TypeConverter.StrToDouble(fc["hidELong"], 0);
            return(View(model));
        }
Exemplo n.º 10
0
 public void UpdateUser(User u)
 {
     if (!UsersContainsUsername(u.Username))
     {
         return;
     }
     Data.Users dUser = _db.Users.Find((u.Username));
     dUser.FirstName   = u.FirstName;
     dUser.LastName    = u.LastName;
     dUser.Email       = u.Email;
     dUser.Phone       = u.Phone;
     dUser.FavLocation = u.FavStore;
 }
Exemplo n.º 11
0
        public ActionResult Reg(FormCollection fc)
        {
            var model = new Data.Users();

            model.Address      = "";
            model.CreateTime   = DateTime.Now;
            model.EndLat       = 0;
            model.EndLong      = 0;
            model.EndTime      = DateTime.Now;
            model.Names        = fc["Names"];
            model.Password     = Encrypt.DES.Des_Encrypt(fc["Password"]);
            model.Phone        = fc["Phone"];
            model.StartLat     = 0;
            model.StartLong    = 0;
            model.StartTime    = DateTime.Now;
            model.WXUserID     = iRequest.GetQueryInt("WxID", 0);
            model.isFinal      = true;
            model.ParentUserID = 0;
            model.Sex          = 1;
            model.EndAddress   = "";
            model.StateID      = 0;
            model.Number       = GetNumber();
            var cint = CheckVCode(fc["Vcode"].ToString(), model.Phone);

            if (cint == 0)
            {
                return(Json(new { success = false, message = "验证码错误." }, JsonRequestBehavior.AllowGet));
            }
            else if (cint == 1)
            {
                return(Json(new { success = false, message = "验证码过期." }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                var userID = Data.UsersDB.AddUsers(model);
                if (userID > 0)
                {
                    SetLocal(fc, userID);
                    Cookie.WriteCookie("UserID", model.Phone);
                    return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { success = false, message = "注册发生异常." }, JsonRequestBehavior.AllowGet));
                }
            }



            //return View();
        }
Exemplo n.º 12
0
        /// <summary>
        /// Kiểm tra người dùng đăng nhập vào có hợp lệ không
        /// </summary>
        /// <Modified>
        ///     Author      Date        Comments
        ///     Cuongdb    19/2/2008    Tạo mới
        /// </Modified>
        public static bool ValidateLogin(string strUserName, string mPassword)
        {
            Data.Users objUsers     = new Data.Users();
            string     mEncPassWord = StringTools.EncryptPassword(mPassword);

            if (objUsers.ValidateLogin(strUserName, mEncPassWord) > 0)
            {
                LayThongTinVaiTro_Quyen(strUserName);
                LayThongTinNguoiDung(strUserName);
                return(true);
            }

            return(false);
        }
Exemplo n.º 13
0
        public ActionResult MRegister(FormCollection fc)
        {
            //try
            //{
            var model = new Data.Users();

            model.Address    = "";
            model.CreateTime = DateTime.Now;
            model.EndLat     = TypeConverter.StrToDouble(fc["hidELat"], 0);
            model.EndLong    = TypeConverter.StrToDouble(fc["hidELong"], 0);
            model.StartLat   = TypeConverter.StrToDouble(fc["hidSLat"], 0);
            model.StartLong  = TypeConverter.StrToDouble(fc["hidSLong"], 0);
            model.Address    = fc["beginAddress"];
            model.EndAddress = fc["EndAddress"];

            model.Sex       = TypeConverter.StrToInt(fc["Sex"], 1);
            model.StartTime = TypeConverter.StrToDateTime(fc["StartTime"]);
            model.EndTime   = TypeConverter.StrToDateTime(fc["EndTime"]);
            model.Names     = fc["Names"];
            model.Password  = Encrypt.DES.Des_Encrypt(fc["Password"]);
            model.Phone     = fc["Phone"];


            model.WXUserID     = iRequest.GetQueryInt("WxID", 0);
            model.isFinal      = true;
            model.ParentUserID = 0;


            model.StateID = 0;
            model.Number  = GetNumber();
            var q  = QueryBuilder.Create <Data.Users>().Equals(x => x.Phone, model.Phone);
            var _m = Data.UsersDB.GETUsers(q);

            if (_m != null)
            {
                return(Json(new { success = false, message = "该手机号已经注册." }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                if (SendCodes(model.Phone))
                {
                    return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { success = false, message = "发送手机短信验证码失效." }, JsonRequestBehavior.AllowGet));
                }
            }
        }
Exemplo n.º 14
0
        public ActionResult MyInfo(FormCollection fc)
        {
            var model = new Data.Users();

            model.ID          = umodel.ID;
            model.Names       = fc["Names"];
            model.Phone       = fc["Phone"];
            model.Sex         = TypeConverter.StrToInt(fc["Sex"]);
            model.EMail       = fc["EMail"];
            model.QQ          = fc["QQ"];
            model.CompanyName = fc["CompanyName"];
            var flag = Data.UsersDB.SaveEditUsersMyInfo(model);

            return(Json(new { success = flag }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 15
0
        public async Task <IActionResult> OnPostAsync(string returnUrl = null)
        {
            returnUrl      = returnUrl ?? Url.Content("~/");
            ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
            if (ModelState.IsValid)
            {
                var user = new Data.Users {
                    UserName = Input.Email, Email = Input.Email, FullName = Input.FullName, CreatedDate = DateTime.UtcNow, Gender = Input.Gender
                };
                var result = await _userManager.CreateAsync(user, Input.Password);

                if (result.Succeeded)
                {
                    _logger.LogInformation("User created a new account with password.");

                    var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                    code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
                    var callbackUrl = Url.Page(
                        "/Account/ConfirmEmail",
                        pageHandler: null,
                        values: new { area = "Identity", userId = user.Id, code = code, returnUrl = returnUrl },
                        protocol: Request.Scheme);

                    await _emailSender.SendEmailAsync(Input.Email, "Confirm your email",
                                                      $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>.");

                    if (_userManager.Options.SignIn.RequireConfirmedAccount)
                    {
                        return(RedirectToPage("RegisterConfirmation", new { email = Input.Email, returnUrl = returnUrl }));
                    }
                    else
                    {
                        await _signInManager.SignInAsync(user, isPersistent : false);

                        return(LocalRedirect(returnUrl));
                    }
                }
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }

            // If we got this far, something failed, redisplay form
            return(Page());
        }
Exemplo n.º 16
0
        void SetLocal(FormCollection f, int UID)
        {
            var um = new Data.Users();

            um.ID         = UID;
            um.Address    = f["hidSAddress"];
            um.EndAddress = f["hidEAddress"];

            um.StartLat  = TypeConverter.StrToDouble(f["hidSLat"], 0);
            um.StartLong = TypeConverter.StrToDouble(f["hidSLong"], 0);
            um.EndLat    = TypeConverter.StrToDouble(f["hidELat"], 0);
            um.EndLong   = TypeConverter.StrToDouble(f["hidELong"], 0);
            if (um.Address != "" && um.EndAddress != "" && um.StartLat > 0 && um.StartLong > 0 && um.EndLat > 0 && um.EndLong > 0)
            {
                Data.UsersDB.SetUserLocal(um);
            }
        }
Exemplo n.º 17
0
        public ActionResult EditMap(FormCollection fc)
        {
            var model = new Data.Users();

            model.ID        = TypeConverter.StrToInt(fc["hidUserID"]);
            model.StartLat  = TypeConverter.StrToDouble(fc["StartLat"], 0);
            model.Address   = fc["add"];
            model.StartLong = TypeConverter.StrToDouble(fc["StartLong"], 0);
            AjaxJson aj = new AjaxJson();

            if (model.ID > 0)
            {
                aj.success = Data.UsersDB.SaveEditUsers_Map(model);
            }
            //else
            //{
            //    aj.success = Data.UsersDB.AddUsers(model) > 0;
            //}
            return(Json(new { success = aj.success }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 18
0
 public ActionResult iMap(FormCollection fc)
 {
     if (umodel == null || umodel.ID < 1)
     {
         return(Json(new { success = false, msg = 1 }, JsonRequestBehavior.AllowGet));
     }
     else
     {
         var model = new Data.Users();
         model.ID        = TypeConverter.StrToInt(fc["hidUserID"]);
         model.StartLat  = TypeConverter.StrToDouble(fc["StartLat"], 0);
         model.Address   = fc["add"];
         model.StartLong = TypeConverter.StrToDouble(fc["StartLong"], 0);
         AjaxJson aj = new AjaxJson();
         if (model.ID > 0)
         {
             aj.success = Data.UsersDB.SaveEditUsers_Map(model);
         }
         return(Json(new { success = aj.success }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 19
0
        public ActionResult EditMyProfile(FormCollection fc)
        {
            var model = new Data.Users();

            model.ID = TypeConverter.StrToInt(fc["hidUserID"]);
            //model.StartLat = TypeConverter.StrToDouble(fc["StartLat"], 0);
            //model.EndLong = TypeConverter.StrToDouble(fc["EndLong"], 0);
            //model.EndLat = TypeConverter.StrToDouble(fc["EndLat"], 0);
            model.CreateTime   = DateTime.Now;
            model.EndAddress   = fc["EndAddress"];
            model.ParentUserID = iRequest.GetQueryInt("ParentID", 0);

            model.WXUserID = 0;
            model.isFinal  = true;
            model.Address  = fc["Address"];
            string _starttime = DateTime.Now.ToString("yyyy-MM-dd");

            _starttime      = _starttime + " " + fc["StartTime1"] + ":" + fc["StartTime2"] + ":00";
            model.StartTime = TypeConverter.StrToDateTime(_starttime);

            string _endtime = DateTime.Now.ToString("yyyy-MM-dd");

            _endtime      = _endtime + " " + fc["EndTime1"] + ":" + fc["EndTime2"] + ":00";
            model.EndTime = TypeConverter.StrToDateTime(_endtime);
            //model.StartLong = TypeConverter.StrToDouble(fc["StartLong"], 0);
            AjaxJson aj = new AjaxJson();

            if (model.ID > 0)
            {
                aj.success = Data.UsersDB.SaveEditUsers_NoMap(model);
            }
            else
            {
                aj.success = Data.UsersDB.AddUsers(model) > 0;
            }
            return(Json(new { success = aj.success }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 20
0
 /// <summary>
 /// Cập nhật thông tin người dùng
 /// </summary>
 /// <modified>
 /// Người tạo            Ngày tạo            chú thích
 /// thinhpq                20/01/2009              Create new
 /// </modified>
 public void UpdateOneUser(string UserName, string FullName, string PassWord, string Email)
 {
     Data.Users clsUsers = new Data.Users();
     clsUsers.UpdateOneUser(UserName, FullName, PassWord, Email);
 }
 public static User Map(Data.Users user, string userLocation) => new User
 {
     FirstName    = user.FirstName,
     LastName     = user.LastName,
     LocationName = userLocation
 };
 public AppleController(Data.Users users)
 {
     this.Users = users;
 }