コード例 #1
0
        public ActionResult Signin1(UserCreateModel usersData, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    UserCreateHandler userCreateHandler = new UserCreateHandler();
                    UsersAddHandler usersAddHandler = new UsersAddHandler();
                    User user1 = usersAddHandler.Find(usersData.Email);

                    if (user1 != null && user1.IsOwner)
                        throw new ValidationException("Email", "Owner's Email already exists");

                    if (userCreateHandler.ExistsUserWithSameUserName(usersData.UserName))
                        throw new ValidationException("UserName", "Owner's UserName already exists");

                    string url = GetRandomString(20);
                    //storing information about new user
                    var user = Core.User.CreateOwner(usersData.FirstName, usersData.LastName, usersData.UserName, usersData.Password, usersData.Email, null, null, usersData.CountryId, null, 0, 0, null, 0, System.DateTime.Now, 1, 0, url, false, false, true, false, false);
                    UsersAddHandler.Save(user);
                    userCreateHandler.Handle(user);

                    //Add path for new photo
                    var path = "/Swisskip/" + user.UserName;
                    if (!System.IO.Directory.Exists(Server.MapPath(path)))
                        System.IO.Directory.CreateDirectory(Server.MapPath(path));

                    //Creating a default photo
                    string newFile = Server.MapPath("/Content/images/") + user.UserName + ".jpg";
                    if (file != null)
                    {
                        file.SaveAs(newFile);
                    }
                    else
                    {
                        if (!System.IO.File.Exists(newFile))
                            System.IO.File.Copy(Server.MapPath("/Content/images/unknown.jpg"), Server.MapPath("/Content/images/") + user.UserName + ".jpg");
                    }

                    //Link new owner with Trial Mode - Status=1 : new owner
                    var user_userType1 = User_UserType.CreateRelationUserAndUserType(0, user.Id, (int)UserRoles.Owner, 0, System.DateTime.Now, 0, 0, 1);
                    UsersAddHandler.Save(user_userType1);

                }
                catch (ValidationException e)
                {
                    ModelState.AddModelError(e.Key, e.Message);
                    return this.View();
                }

                return RedirectToAction("MailVerification", "Authentication");
            }
            return this.View();
        }
コード例 #2
0
        public ActionResult SecretInfo(AccountEditModel form)
        {
            try
            {
                User ExistedUser = (User)Session["user"];
                ExistedUser.ColourId = form.ColourId;
                ExistedUser.IconId = form.IconId;
                ExistedUser.SecretPhrase = form.SecretPhrase;
                UsersAddHandler usersAddHandler = new UsersAddHandler();
                usersAddHandler.Update(ExistedUser);

                return RedirectToAction("SignIn", "Authentication");
            }
            catch (ValidationException e)
            {
                ModelState.AddModelError(e.Key, e.Message);
                return this.View();
            }
        }
コード例 #3
0
        public ActionResult Signin5(AccountEditModel form)
        {
            //if (ModelState.IsValid)
            //{
                try
                {

                    User currentUser = (User)Session["Signin1Store"];
                    UsersAddHandler usersAddHandler = new UsersAddHandler();
                    User ExistedUser = usersAddHandler.Find(currentUser.Email);
                    ExistedUser.ColourId = form.ColourId;
                    ExistedUser.IconId = form.IconId;
                    ExistedUser.SecretPhrase = form.SecretPhrase;
                    usersAddHandler.Update(ExistedUser);

                    Session["Signin1Store"] = currentUser;
                    Session["Signin2Store"] = Session["Signin2Store"];
                    Session["Signin3Store"] = Session["Signin3Store"];
                    //Session["Signin4Store"] = Session["Signin4Store"];
                    return RedirectToAction("Signin6", "Registration");

                }
                catch (ValidationException e)
                {
                    ModelState.AddModelError(e.Key, e.Message);
                    return this.View();
                }
            //}

            return RedirectToAction("Signin6", "Registration");
        }
コード例 #4
0
        public ActionResult Signin4(MessageModel form)
        {
            User usersData = null ;
            DataheirCreateModel dataheirData = null;
            List<DataheirCreateModel> witnessData = null;

            if (ModelState.IsValid)
            {
                try
                {
                    //storing information about new user
                    UsersAddHandler usersAddHandler1 = new UsersAddHandler();
                    usersData = (User)Session["Signin1Store"];
                    User user = usersAddHandler1.Find(usersData.Email);
                    //UserCreateHandler userCreateHandler = new UserCreateHandler();

                    //var user = Core.User.CreateOwner(usersData.FirstName, usersData.LastName, usersData.UserName, usersData.Password, usersData.Email, usersData.CountryId, 0, 0, null, 0, System.DateTime.Now, 1, 0, false, false, true, false, false);
                    //UsersAddHandler.Save(user);
                    //userCreateHandler.Handle(user);

                    ////Add path for new photo
                    //var path = "~/Swisskip/" + user.UserName;
                    //if (!System.IO.Directory.Exists(Server.MapPath(path)))
                    //    System.IO.Directory.CreateDirectory(Server.MapPath(path));

                    //Session["path"] = path;
                    ////Session["username"] = user.UserName;

                    ////Creating a default photo
                    //string newFile = Server.MapPath("~/Content/images/") + user.UserName + ".jpg";
                    //if (!System.IO.File.Exists(newFile))
                    //    System.IO.File.Copy(Server.MapPath("~/Content/images/unknown.jpg"), Server.MapPath("~/Content/images/") + user.UserName + ".jpg");

                    //AuthenticationService.SignIn(user);

                    ////Link new owner with Trial Mode - Status=1 : new owner
                    //var user_userType1 = User_UserType.CreateRelationUserAndUserType(0, user.Id, (int)UserRoles.Owner, 0, System.DateTime.Now, 0, 0, 1);
                    //UsersAddHandler.Save(user_userType1);

                    dataheirData = (DataheirCreateModel)Session["Signin2Store"];
                    DataheirAddHandler dataheirAddHandler = new DataheirAddHandler();

                    //Validating Dataheir's Email already existed
                    UsersAddHandler usersAddHandler = new UsersAddHandler();
                    User ExistedUser = usersAddHandler.Find(dataheirData.Email);
                    User dataheir = new User();

                    //Find info already existed in DB
                    if (ExistedUser != null && ExistedUser.Email == dataheirData.Email)
                    {
                        ExistedUser.IsDataheir = true;
                        usersAddHandler.Update(ExistedUser);
                        dataheir = ExistedUser;
                        ExistedUser = null;
                    }
                    else
                    {
                        dataheir = Core.User.CreateDataheir(dataheirData.FirstName, dataheirData.LastName, dataheirData.UserName, dataheirData.Password, dataheirData.Email, null, null, dataheirData.CountryId, null, 0, 0, null, 0, System.DateTime.Now, 0, 0, null, false, false, false, true, false);
                        UsersAddHandler.Save(dataheir);
                    }

                    //Sent Confirmation
                    dataheirAddHandler.Handle(user, dataheir, form.DataheirMsg);

                    //Link new owner with Trial Mode
                    var user_userType2 = User_UserType.CreateRelationUserAndUserType(user.Id, dataheir.Id, (int)UserRoles.Dataheir, 0, System.DateTime.Now, 0, 0, 0);
                    UsersAddHandler.Save(user_userType2);

                    //Create Witness
                    witnessData = (List<DataheirCreateModel>)Session["Signin3Store"];
                    WitnessesAddHandler witnessAddHandler = new WitnessesAddHandler();
                    User witness = new User();

                    for (int i = 0; i < witnessData.Count; i++)
                    {
                        //Adding validations - new!
                        User ExistedUser1 = usersAddHandler.Find(witnessData[i].Email);

                        if (ExistedUser1 != null && ExistedUser1.Email == witnessData[i].Email)
                        {
                            ExistedUser1.IsWitness = true;
                            usersAddHandler.Update(ExistedUser1);
                            witness = ExistedUser1;
                        }
                        else
                        {
                            witness = Core.User.CreateWitness(witnessData[i].FirstName, witnessData[i].LastName, witnessData[i].UserName, witnessData[i].Password, witnessData[i].Email, null, null, witnessData[i].CountryId, null, 0, 0, null, 0, System.DateTime.Now, 0, 0, null, false, false, false, false, true);
                            UsersAddHandler.Save(witness);
                        }

                        //Sent Confirmation
                        witnessAddHandler.Handle(user, witness, form.WitnessMsg);

                        //Link new owner with Trial Mode
                        var user_userType3 = User_UserType.CreateRelationUserAndUserType(user.Id, witness.Id, (int)UserRoles.Witness, 0, System.DateTime.Now, 0, 0, 0);
                        UsersAddHandler.Save(user_userType3);
                        witness = null;
                        ExistedUser1 = null;
                    }

                }
                catch (ValidationException e)
                {
                    ModelState.AddModelError(e.Key, e.Message);
                    return this.View();
                }
            }

            //if (!ModelState.IsValid)
            //    return this.View();

            //if (invitationId.HasValue)
            //{
            //User user1 = Current.Connection.Get<User>(Current.UserId);
            //AuthenticationService.SignIn(user1);
            //    return new RedirectToAccountType(user);
            //}

            Session["Signin1Store"] = usersData;
            Session["Signin2Store"] = dataheirData;
            Session["Signin3Store"] = witnessData;
            return RedirectToAction("Signin5", "Registration");
        }
コード例 #5
0
 public ActionResult Signin2(string userId, string type)
 {
     UsersAddHandler usersAddHandler = new UsersAddHandler();
     User user = usersAddHandler.Find2(userId, type);
     Session["Signin1Store"] = user;
     return View();
 }
コード例 #6
0
        public ActionResult SignIn(string V, string type, SignInModel model, string returnUrl)
        {
            User user = null;
            if (ModelState.IsValid)
            {
                try
                {
                    user = new SignInHandler().Handle(model);
                    if (user.Banned)
                        return RedirectToAction("BannedAccount");
                    //if (user.Blocked)
                    //    return RedirectToAction("BlockedAccount");

                    if (type != null)
                    {
                        Session["AccessDenied"] = 1;
                        return RedirectToAction("Signin2", "Registration", new { userId = V, type = type });
                    }
                }
                catch (ValidationException e)
                {
                    ModelState.AddModelError(e.Key, e.Message);
                }
            }
            else
            {
                ModelState.AddModelError("", "Forgot username or passoword");
                return this.View();
            }

            if (!ModelState.IsValid)
                return this.View();

            AuthenticationService.SignIn(user);
            Session["path"] = Server.MapPath("~/Swisskip/") + user.UserName;

            //Sent TOKEN by email
            int newValue = SignInHandler.SendInvitation(user);

            //Added Token into account
            UsersAddHandler usersAddHandler = new UsersAddHandler();
            user.TokenNumber = newValue;
            usersAddHandler.Update(user);

            //Validating data entry

            if (user.ColourId == 0 && user.IsOwner == false)
            {
                return RedirectToAction("Reminder");
            }
            else if (user.ColourId == 0 && user.IsOwner)
            {
                return RedirectToAction("MissingInfo", new { id = user.Id });
            }

            Session["AccessDenied"] = 1;
            return RedirectToAction("Confirm");
        }
コード例 #7
0
        public ActionResult Maintained(int? userId, SignInModel model, string returnUrl)
        {
            User user = null;
            if (ModelState.IsValid)
            {
                try
                {
                    user = new SignInHandler().Handle(model);
                    if (user.Banned)
                        return RedirectToAction("BannedAccount");
                    //if (user.Blocked)
                    //    return RedirectToAction("BlockedAccount");
                }
                catch (ValidationException e)
                {
                    ModelState.AddModelError(e.Key, e.Message);
                }
            }
            else
            {
                ModelState.AddModelError("", "Forgot username or passoword");
                return this.View();
            }

            if (!ModelState.IsValid)
                return this.View();

            AuthenticationService.SignIn(user);
            Session["path"] = Server.MapPath("~/Swisskip/") + user.UserName;

            //Sent TOKEN by email
            int newValue = SignInHandler.SendInvitation(user);

            //Added Token into account
            UsersAddHandler usersAddHandler = new UsersAddHandler();
            user.TokenNumber = newValue;
            usersAddHandler.Update(user);

            return RedirectToAction("Confirm");
        }