Beispiel #1
0
 def run(self, request, args, output):
     if db.exists('users', {'user': args['user']}) is not False:
         # insert into database
         permissions = perms.LOGIN
         if args['read_only'] is not False:
             permissions = permissions | perms.WRITE
         db.set('users', {'user': args['user'], 'pass': args['pass'],
                          'email': args['email'], 'servers': [],
                          'permissions': permissions,
                          'token': utils.token(args['user'])
         })
     else:
         output['status'] = 7
         output['payload'] = ["user already exists"]
Beispiel #2
0
import plugins.mongodb
DATABASE_HANDLER = plugins.mongodb

# Stuff specific to the mongodb plugin
# Edit these if your mongodb is on a remote server
MONGO_HOST = 'localhost'
MONGO_PORT = 27017
MONGO_DBNAME = 'eyearesee'

# Make certain users admins or read_only
# (so you don't have to faff around editing the database directly)
# NOTE: This changes the users permissions in the database itself too.
import eyearelib.database as db
import eyearelib.permissions as permissions

for user in ADMINS:
    u = db.get('users', {'user': user})
    if len(u) > 0:
        u = u[0]
        eyearelib.logger.i("Making %s an admin", user)
        u['permissions'] = u['permissions'] | permissions.ADMIN
        db.set('users', u)

for user in READ_ONLY:
    u = db.get('users', {'user': user})
    if len(u) > 0:
        u = u[0]
        eyearelib.logger.i("Making %s a read-only user", user)
        u['permissions'] = u['permissions'] | (not permissions.WRITE)
        db.set('users', u)