Ошибка с новыми пользователями
This commit is contained in:
parent
a86603409c
commit
57cb36d786
3 changed files with 11 additions and 26 deletions
|
@ -203,33 +203,19 @@ class ControllerAPI:
|
|||
return True
|
||||
|
||||
def get(self, user_id):
|
||||
secret = models.UsersSecrets.select().where(
|
||||
models.UsersSecrets.user == user_id
|
||||
)
|
||||
return secret
|
||||
return models.UsersSecrets.select().where(models.UsersSecrets.user == user_id).first()
|
||||
|
||||
def check(self, user_id):
|
||||
if models.UsersSecrets.select().where(
|
||||
models.UsersSecrets.user == user_id
|
||||
).count() == 0:
|
||||
if models.UsersSecrets.select().where(models.UsersSecrets.user == user_id).count() == 0:
|
||||
return False
|
||||
return True
|
||||
|
||||
def set(self, user_id, secret, acl, status):
|
||||
if self.check(user_id):
|
||||
x = models.UsersSecrets.update(
|
||||
secret=secret,
|
||||
acl=acl,
|
||||
status=status
|
||||
).where(
|
||||
x = models.UsersSecrets.update(secret=secret, acl=acl, status=status).where(
|
||||
models.UsersSecrets.user == user_id
|
||||
)
|
||||
x.execute()
|
||||
else:
|
||||
models.UsersSecrets.create(
|
||||
user=user_id,
|
||||
secret=secret,
|
||||
acl=acl,
|
||||
status=status
|
||||
)
|
||||
models.UsersSecrets.create(user=user_id, secret=secret, acl=acl, status=status)
|
||||
return True
|
||||
|
|
|
@ -397,22 +397,21 @@ def sshkey_delete():
|
|||
return redirect(url_for('account.sshkey'))
|
||||
|
||||
|
||||
@viewAccount.route('/api', methods=['GET', 'POST'])
|
||||
def api():
|
||||
@viewAccount.route('/api.html')
|
||||
def api_index():
|
||||
# check session
|
||||
if not ControllerUsers().check_session():
|
||||
return redirect(url_for("account.logout"))
|
||||
# auth user
|
||||
if not ControllerUsers().auth(session['email'], session['password']):
|
||||
if not ControllerUsers().auth(session.get('email'), session.get('password')):
|
||||
return redirect(url_for("account.logout"))
|
||||
#
|
||||
if not ControllerAPI().check(session['user_id']):
|
||||
ControllerAPI().set(session['user_id'], '', '', 0)
|
||||
if not ControllerAPI().check(session.get('user_id')):
|
||||
ControllerAPI().set(user_id=session.get('user_id'), secret='', acl='', status=0)
|
||||
#
|
||||
user_secret = ControllerAPI().get(session['user_id'])[0]
|
||||
return render_template(
|
||||
'default/id/api.html',
|
||||
user_secret=user_secret
|
||||
user_secret=ControllerAPI().get(user_id=session.get('user_id'))
|
||||
)
|
||||
|
||||
|
||||
|
|
2
setup.py
2
setup.py
|
@ -4,7 +4,7 @@ from setuptools import setup
|
|||
|
||||
setup(
|
||||
name='SWSCloudCore',
|
||||
version='2.5.12',
|
||||
version='2.5.13',
|
||||
author='Vyacheslav Anzhiganov',
|
||||
author_email='hello@anzhiganov.com',
|
||||
packages=[
|
||||
|
|
Loading…
Add table
Reference in a new issue