Skip to content

Commit

Permalink
Maintain user admin with the admin server password
Browse files Browse the repository at this point in the history
  • Loading branch information
greghaynes committed May 28, 2010
1 parent f1dcde3 commit 0b19dc6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/pyscripts/xsbs/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def main():
pm.loadPlugins()
setup_all()
create_all()
xsbs.server.setupAdminUser()

main()

24 changes: 23 additions & 1 deletion src/pyscripts/xsbs/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
from xsbs.ui import notice
from xsbs.colors import colordict
from xsbs.settings import PluginConfig
from xsbs.users import User
from xsbs.users.privilege import UserPrivilege

from sqlalchemy.orm.exc import NoResultFound
from elixir import session

import string
import sbserver
Expand All @@ -20,6 +25,23 @@
'private',
]

def setupAdminUser():
try:
adminUser = User.query.filter(User.email=="admin").one()
except NoResultFound:
adminUser = User("admin", sbserver.adminPassword())
session.commit()
adminUser = User.query.filter(User.email=="admin").one()
else:
if adminUser.password != sbserver.adminPassword():
adminUser.password = sbserver.adminPassword()
adminUser.update()
try:
adminPriv = UserPrivilege.query.filter(UserPrivilege.user_id==adminUser.id).one()
except NoResultFound:
adminPriv = UserPrivilege(2, adminUser.id)
session.commit()

def isPaused():
'''Is the game currently paused'''
return sbserver.isPaused()
Expand Down Expand Up @@ -121,4 +143,4 @@ def csevalfile(file):
cseval(f.read())
except: pass
finally:
f.close()
f.close()

0 comments on commit 0b19dc6

Please sign in to comment.