Update login

Add profile
This commit is contained in:
RemiZOffAlex
2019-04-26 19:38:23 +03:00
parent bba7df52d2
commit 1e9ac7eb97
17 changed files with 237 additions and 46 deletions

View File

@@ -7,6 +7,6 @@ __url__ = 'https://remizoffalex.ru'
from .pagination import Pagination, getpage
from .passwd import pwgen, get_hash_password
from .storage import gettree, gethashtree
from .info import get_user, get_ip
from .info import get_user
__all__ = []

View File

@@ -23,14 +23,3 @@ def get_user():
session.pop('user_id', None)
return None
return result
def get_ip():
"""
Получить IP
"""
result = ''
if request.headers.getlist("X-Forwarded-For"):
result = request.headers.get("X-Forwarded-For").split(",")[0]
else:
result = request.remote_addr
return result

View File

@@ -1,35 +1,32 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
__author__ = 'RemiZOffAlex'
__copyright__ = '(c) RemiZOffAlex'
__license__ = 'MIT'
__email__ = 'remizoffalex@mail.ru'
__url__ = 'https://remizoffalex.ru'
import uuid
import random
import hashlib
from .. import app
def pwgen(length=15, hex=False):
"""
Генератор пароля
"""
keylist='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
keylist = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
if hex:
keylist='0123456789ABCDEF'
password=[]
keylist = '0123456789ABCDEF'
password = []
while len(password) < length:
a_char = random.choice(keylist)
password.append(a_char)
return ''.join(password)
def get_hash_password(password, salt = None):
def get_hash_password(password, salt=None):
"""
Получить хеш пароля SHA-512
"""
if salt == None:
if salt is None:
salt = uuid.uuid4().hex
text = password.encode('utf-8') + salt.encode('utf-8')
h = hashlib.sha512()