Ejemplo n.º 1
0
        public ActionResult Sqrl(string id, string publickey, string signature, string url)
        {
            var data = new SqrlData
            {
                PublicKey = HttpServerUtility.UrlTokenDecode(publickey),
                Signature = HttpServerUtility.UrlTokenDecode(signature),
                Url = url
            };

            var expected = string.Format("{0}/{1}",
                                         Url.Action("Sqrl",
                                                    "Login",
                                                    null,
                                                    "sqrl",
                                                    Request.Url.Host + ":" + Request.Url.Port),
                                         id);

            if(_sqrlServer.VerifySqrlRequest(data, expected) && _nutRepository.IsNutActive(id))
            {
                var user = _userRepository.Retrieve(publickey);

                if(user == null)
                {
                    // register user
                    user = new SqrlUser
                    {
                        Id = publickey,
                        Initialized = false
                    };

                    _userRepository.Create(user);
                }

                _nutRepository.Validate(id, user.Id);

                return Content("valid");
            }

            return Content("invalid");
        }
Ejemplo n.º 2
0
 public ActionResult Register(SqrlUser user)
 {
     user.Initialized = true;
     _userRepository.Update(user);
     return RedirectToAction("Welcome", "Home");
 }