Ejemplo n.º 1
0
        public bool Exec(LocalNetwork network, DtoCheckToken obj)
        {
            try
            {
                using (var db = GetConnection(network))
                {
                    var user = repository.GetUserBySocial(db, obj.sID);

                    if (user == null)
                    {
                        Error = new DtoServiceError
                        {
                            message   = getLanguage(obj._language, 1),
                            debugInfo = "[1]"
                        };

                        return(false);
                    }

                    if (user.stToken != obj.sToken)
                    {
                        Error = new DtoServiceError
                        {
                            message   = getLanguage(obj._language, 2),
                            debugInfo = "[1]"
                        };

                        return(false);
                    }

                    if (DateTime.Now > user.dtTokenExpires)
                    {
                        Error = new DtoServiceError
                        {
                            message   = getLanguage(obj._language, 3),
                            debugInfo = "[1]"
                        };

                        return(false);
                    }

                    user.bTokenized = true;

                    repository.UpdateUser(db, user);
                }

                return(true);
            }
            catch (Exception ex)
            {
                Error = new DtoServiceError
                {
                    message   = getLanguage(obj._language, 0),
                    debugInfo = ex.ToString()
                };

                return(false);
            }
        }
Ejemplo n.º 2
0
        public ActionResult Post([FromBody] DtoCheckToken obj)
        {
            var repo = new DapperUserRepository();
            var srv  = new SrvCheckTokenV1(repo);

            if (!srv.Exec(network, obj))
            {
                return(BadRequest(srv.Error));
            }

            return(Ok(new { }));
        }