public ActionResult CreateUser(UserViewModel model)
        {
            long mSsn;
            if (ModelState.IsValid)
            {
                model.Ssn = model.Ssn.Replace("-", "");
                model.Ssn = model.Ssn.Replace(".", "");
                if (long.TryParse(model.Ssn, out mSsn))
                {
                    User user = new User
                                {
                                    fname = model.FirstName,
                                    lname = model.SurName,
                                    created_timestamp = DateTime.Now,
                                    uname = model.UserName,
                                    email = model.EMail,
                                    is_active = true,
                                    passwd = model.Password,
                                    phoneno = model.PhoneNo,
                                    sec_group = "User",
                                    ssn = Encoding.UTF8.GetBytes(mSsn.ToString()),
                                    zipcode = model.ZipCode,
                                    street = model.Street
                                };

                    bool success = new UserLogic().SaveUser(user);
                    if (success)
                        return View("../Home/Index");
                }
            }

            return View(model);
        }
 public ActionResult <IEnumerable <string> > Get()
 {
     Repository.Models.User user = new Repository.Models.User();
     user.CreatedDate = DateTime.Now;
     user.Email       = Guid.NewGuid() + baseMail;
     user.FirstName   = "test";
     user.LastName    = "user";
     user.Password    = "******";
     userService.add(user);
     return(new string[] { "value1", "value2" });
 }
Ejemplo n.º 3
0
 public SitePrincipal(User user)
 {
     Identity = new SiteIdentity(user);
 }
Ejemplo n.º 4
0
 public SiteIdentity(User user)
 {
     Name = user.Login;
     Id = user.Id;
 }
Ejemplo n.º 5
0
        public async Task<ActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl)
        {
            if (User.Identity.IsAuthenticated)
            {
                return RedirectToAction("Index", "Manage");
            }

            if (ModelState.IsValid)
            {
                // Get the information about the user from the external login provider
                var info = await AuthenticationManager.GetExternalLoginInfoAsync();
                if (info == null)
                {
                    return View("ExternalLoginFailure");
                }
                var user = new User { UserName = model.Email, Email = model.Email };
                var result = await UserManager.CreateAsync(user);
                if (result.Succeeded)
                {
                    result = await UserManager.AddLoginAsync(user.Id, info.Login);
                    if (result.Succeeded)
                    {
                        await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
                        return RedirectToLocal(returnUrl);
                    }
                }
                AddErrors(result);
            }

            ViewBag.ReturnUrl = returnUrl;
            return View(model);
        }
Ejemplo n.º 6
0
        public async Task<ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new User { UserName = model.Email, Email = model.Email };
                var result = await UserManager.CreateAsync(user, model.Password);
                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);
                    
                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return RedirectToAction("Index", "Home");
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
Ejemplo n.º 7
0
        public UserLoginDto CheckCredentials(User user)
        {
            int statuscode = 0;
            UserLoginDto returned_user = new UserLoginDto();

            var dbuser = db.Users.FirstOrDefault(d => d.Username == user.Username);
            if (dbuser == null)
            {
                //user doesnt exist
                statuscode = 0;
            }
            else
            {
                if (user.Password != dbuser.Password)
                {
                    // wrong password
                    statuscode = 1;
                }
                else if (user.Password == dbuser.Password)
                {
                    //username and password are correct
                    statuscode = 2;

                    returned_user.UserId = dbuser.UserId;
                    returned_user.LoginStatusCode = statuscode;
                }
            }
            return returned_user;
        }
Ejemplo n.º 8
0
 public void AddUser(User user)
 {
     user.Role = 0;
     db.Users.Add(user);
     SaveChanges();
 }
Ejemplo n.º 9
0
 public bool CheckUserIfExists(User user)
 {
     var dbuser = db.Users.FirstOrDefault(d => d.Username == user.Username);
     // if given user doesn't exist
     if (dbuser == null)
     {
         return false;
     }
     else
     {
         return true;
     }
 }
Ejemplo n.º 10
0
 public void Update(User user)
 {
     _ctx.Entry(user).State = EntityState.Modified;
 }
Ejemplo n.º 11
0
 public void Add(User user)
 {
     throw new NotImplementedException();
 }
 public bool CreateUser(User user)
 {
     return new UserService().CreateUser(user);
 }
 public bool UpdateUser(User user)
 {
     return new UserService().UpdateUser(user);
 }