Ejemplo n.º 1
0
        public ActionResult CreateGoogleUser(GoogleUser user)
        {
            if (string.IsNullOrEmpty(user.Name))
            {
                return(View(user));
            }
            if (user.Name.Length > 100)
            {
                user.Error = "Name for display should be shorter than 100 characters.";
                return(View(user));
            }
            var res = Model.RegisterGoogleUser(user.Name, user.EmailHash);

            if (!string.IsNullOrEmpty(res.Error))
            {
                user.Error = "Error occured. Try again later.";
                return(View(user));
            }
            if (res.NameTaken)
            {
                user.Error = "This name is already taken.";
                return(View(user));
            }

            SessionManager.SetAuthentication(user.Name);
            if (!string.IsNullOrEmpty(user.redirectInfo))
            {
                return(this.Redirect(Utils.Utils.BaseUrl + user.redirectInfo));
            }
            else
            {
                return(this.RedirectToAction("UsersStuff"));
            }
        }
Ejemplo n.º 2
0
        public ActionResult CreateGoogleUser(GoogleUser user)
        {
            if (string.IsNullOrEmpty(user.Name))
                return View(user);
            if (user.Name.Length > 100)
            {
                user.Error = "Name for display should be shorter than 100 characters.";
                return View(user);
            }
            var res = Model.RegisterGoogleUser(user.Name, user.EmailHash);
            if (!string.IsNullOrEmpty(res.Error))
            {
                user.Error = "Error occured. Try again later.";
                return View(user);
            }
            if (res.NameTaken)
            {
                user.Error = "This name is already taken.";
                return View(user);
            }

            SessionManager.SetAuthentication(user.Name);
            if (!string.IsNullOrEmpty(user.redirectInfo))
                return this.Redirect(Utils.Utils.BaseUrl + user.redirectInfo);
            else
                return this.RedirectToAction("UsersStuff");
        }