fix auth error and simplify url and email checks
This commit is contained in:
parent
5430bc2cdd
commit
87548030cb
@ -109,7 +109,8 @@ def login(request):
|
|||||||
return redirect(request, "index")
|
return redirect(request, "index")
|
||||||
|
|
||||||
login_failed = True
|
login_failed = True
|
||||||
remote_addr = request.access_route[-1] or request.remote_addr
|
remote_addr = (request.access_route and request.access_route[-1]
|
||||||
|
or request.remote_addr)
|
||||||
_log.warn("Failed login attempt from %r", remote_addr)
|
_log.warn("Failed login attempt from %r", remote_addr)
|
||||||
|
|
||||||
return render_to_response(
|
return render_to_response(
|
||||||
|
@ -14,21 +14,15 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from wtforms.validators import Email, URL
|
import six
|
||||||
|
|
||||||
def validate_email(email):
|
def validate_email(email):
|
||||||
"""
|
"""
|
||||||
Validates an email
|
Validates an email
|
||||||
|
|
||||||
Returns True if valid and False if invalid
|
Returns True if valid and False if invalid
|
||||||
"""
|
"""
|
||||||
|
return '@' in email
|
||||||
email_re = Email().regex
|
|
||||||
result = email_re.match(email)
|
|
||||||
if result is None:
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
return result.string
|
|
||||||
|
|
||||||
def validate_url(url):
|
def validate_url(url):
|
||||||
"""
|
"""
|
||||||
@ -36,11 +30,9 @@ def validate_url(url):
|
|||||||
|
|
||||||
Returns True if valid and False if invalid
|
Returns True if valid and False if invalid
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
url_re = URL().regex
|
six.moves.urlparse(url)
|
||||||
result = url_re.match(url)
|
return True
|
||||||
if result is None:
|
except Except as e:
|
||||||
return False
|
return False
|
||||||
else:
|
|
||||||
return result.string
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user