mirror of
https://github.com/simple-login/app.git
synced 2024-11-16 00:48:32 +01:00
add delete() to ModelMixin: do NOT use the session.delete(), somehow it does a "SET" before "DELETE"
This commit is contained in:
parent
a2225160d5
commit
1274dd589a
6 changed files with 8 additions and 7 deletions
|
@ -41,7 +41,7 @@ def activate():
|
||||||
login_user(user)
|
login_user(user)
|
||||||
|
|
||||||
# activation code is to be used only once
|
# activation code is to be used only once
|
||||||
activation_code.delete()
|
ActivationCode.delete(activation_code.id)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
flash("Your account has been activated", "success")
|
flash("Your account has been activated", "success")
|
||||||
|
|
|
@ -49,7 +49,7 @@ def reset_password():
|
||||||
user.activated = True
|
user.activated = True
|
||||||
|
|
||||||
# remove the reset password code
|
# remove the reset password code
|
||||||
reset_password_code.delete()
|
ResetPasswordCode.delete(reset_password_code.id)
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
login_user(user)
|
login_user(user)
|
||||||
|
|
|
@ -57,7 +57,7 @@ def client_detail(client_id):
|
||||||
|
|
||||||
# replace all uris. TODO: optimize this?
|
# replace all uris. TODO: optimize this?
|
||||||
for redirect_uri in client.redirect_uris:
|
for redirect_uri in client.redirect_uris:
|
||||||
redirect_uri.delete()
|
RedirectUri.delete(redirect_uri.id)
|
||||||
|
|
||||||
for uri in uris:
|
for uri in uris:
|
||||||
RedirectUri.create(client_id=client_id, uri=uri)
|
RedirectUri.create(client_id=client_id, uri=uri)
|
||||||
|
|
|
@ -21,7 +21,7 @@ def index():
|
||||||
flash("You cannot remove this client", "warning")
|
flash("You cannot remove this client", "warning")
|
||||||
else:
|
else:
|
||||||
client_name = client.name
|
client_name = client.name
|
||||||
client.delete()
|
Client.delete(client.id)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
LOG.d("Remove client %s", client)
|
LOG.d("Remove client %s", client)
|
||||||
flash(f"Client {client_name} has been deleted successfully", "success")
|
flash(f"Client {client_name} has been deleted successfully", "success")
|
||||||
|
|
|
@ -57,8 +57,9 @@ class ModelMixin(object):
|
||||||
def save(self):
|
def save(self):
|
||||||
db.session.add(self)
|
db.session.add(self)
|
||||||
|
|
||||||
def delete(self):
|
@classmethod
|
||||||
db.session.delete(self)
|
def delete(cls, obj_id):
|
||||||
|
cls.query.filter(cls.id == obj_id).delete()
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
values = ", ".join(
|
values = ", ".join(
|
||||||
|
|
|
@ -64,7 +64,7 @@ def get_access_token():
|
||||||
db.session.add(oauth_token)
|
db.session.add(oauth_token)
|
||||||
|
|
||||||
# Auth code can be used only once
|
# Auth code can be used only once
|
||||||
db.session.delete(auth_code)
|
AuthorizationCode.delete(auth_code.id)
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue