예제 #1
0
    def _do_create(self, req):
        mgr = AccountManager(self.env)

        user = req.args.get('user')
        if not user:
            req.hdf['registration.error'] = 'Username cannot be empty.'
            return

        if mgr.has_user(user):
            req.hdf['registration.error'] = \
                'Another account with that name already exists.'
            return

        # disallow registration of accounts which have existing permissions
        permission_system = perm.PermissionSystem(self.env)
        if permission_system.get_user_permissions(user) != \
           permission_system.get_user_permissions('authenticated'):
            req.hdf['registration.error'] = \
                'Another account with that name already exists.'
            return

        password = req.args.get('password')
        if not password:
            req.hdf['registration.error'] = 'Password cannot be empty.'
            return

        if password != req.args.get('password_confirm'):
            req.hdf['registration.error'] = 'The passwords must match.'
            return

        mgr.set_password(user, password)
        req.redirect(self.env.href.login())
예제 #2
0
파일: web_ui.py 프로젝트: lkraav/trachacks
    def _do_create(self, req):
        mgr = AccountManager(self.env)

        user = req.args.get('user')
        if not user:
            req.hdf['registration.error'] = 'Username cannot be empty.'
            return

        if mgr.has_user(user):
            req.hdf['registration.error'] = \
                'Another account with that name already exists.'
            return

        # disallow registration of accounts which have existing permissions
        permission_system = perm.PermissionSystem(self.env)
        if permission_system.get_user_permissions(user) != \
           permission_system.get_user_permissions('authenticated'):
            req.hdf['registration.error'] = \
                'Another account with that name already exists.'
            return

        password = req.args.get('password')
        if not password:
            req.hdf['registration.error'] = 'Password cannot be empty.'
            return

        if password != req.args.get('password_confirm'):
            req.hdf['registration.error'] = 'The passwords must match.'
            return

        mgr.set_password(user, password)
        req.redirect(self.env.href.login())
예제 #3
0
파일: web_ui.py 프로젝트: AshKash/kit-sink
def _create_user(req, env, check_permissions=True):
    mgr = AccountManager(env)

    user = req.args.get('user')
    name = req.args.get('name')
    email = req.args.get('email')
    acctmgr = {'username' : user,
               'name' : name,
               'email' : email,
              }
    error = TracError('')
    error.acctmgr = acctmgr
    if not user:
        error.message = 'Username cannot be empty.'
        raise error

    if mgr.has_user(user):
        error.message = 'Another account with that name already exists.'
        raise error

    if check_permissions:
        # disallow registration of accounts which have existing permissions
        permission_system = perm.PermissionSystem(env)
        if permission_system.get_user_permissions(user) != \
           permission_system.get_user_permissions('authenticated'):
            error.message = 'Another account with that name already exists.'
            raise error

#     password = req.args.get('password')
#     if not password:
#         error.message = 'Password cannot be empty.'
#         raise error

#     if password != req.args.get('password_confirm'):
#         error.message = 'The passwords must match.'
#         raise error

    db = env.get_db_cnx()
    cursor = db.cursor()
    cursor.execute("REPLACE INTO session "
                   "(sid, authenticated, last_visit) "
                   "VALUES (%s, 1, 0)",
                   (user,))

    for key in ('name', 'email'):
        value = req.args.get(key)
        if not value:
            continue
        cursor.execute("REPLACE INTO session_attribute "
                       "(sid,authenticated,name,value) "
                       "VALUES (%s,1,%s,%s)",
                       (user, key, value))
    db.commit()

    try:
        mgr.set_password(user, "setinldap")
    except TracError, e:
        e.acctmgr = acctmgr
        raise e
예제 #4
0
def _create_user(req, env, check_permissions=True):
    mgr = AccountManager(env)

    user = req.args.get('user')
    if not user:
        raise TracError('Username cannot be empty.')

    if mgr.has_user(user):
        raise TracError('Another account with that name already exists.')

    if check_permissions:
        # disallow registration of accounts which have existing permissions
        permission_system = perm.PermissionSystem(env)
        if permission_system.get_user_permissions(user) != \
           permission_system.get_user_permissions('authenticated'):
            raise TracError('Another account with that name already exists.')

    password = req.args.get('password')
    if not password:
        raise TracError('Password cannot be empty.')

    if password != req.args.get('password_confirm'):
        raise TracError('The passwords must match.')

    mgr.set_password(user, password)

    db = env.get_db_cnx()
    cursor = db.cursor()
    cursor.execute(
        "SELECT count(*) FROM session "
        "WHERE sid=%s AND authenticated=1", (user, ))
    exists, = cursor.fetchone()
    if not exists:
        cursor.execute(
            "INSERT INTO session "
            "(sid, authenticated, last_visit) "
            "VALUES (%s, 1, 0)", (user, ))

    for key in ('name', 'email'):
        value = req.args.get(key)
        if not value:
            continue
        cursor.execute(
            "UPDATE session_attribute SET value=%s "
            "WHERE name=%s AND sid=%s AND authenticated=1", (value, key, user))
        if not cursor.rowcount:
            cursor.execute(
                "INSERT INTO session_attribute "
                "(sid,authenticated,name,value) "
                "VALUES (%s,1,%s,%s)", (user, key, value))
    db.commit()
예제 #5
0
파일: web_ui.py 프로젝트: lkraav/trachacks
def _create_user(req, env, check_permissions=True):
    mgr = AccountManager(env)

    user = req.args.get('user')
    if not user:
        raise TracError('Username cannot be empty.')

    if mgr.has_user(user):
        raise TracError('Another account with that name already exists.')

    if check_permissions:
        # disallow registration of accounts which have existing permissions
        permission_system = perm.PermissionSystem(env)
        if permission_system.get_user_permissions(user) != \
           permission_system.get_user_permissions('authenticated'):
            raise TracError('Another account with that name already exists.')

    password = req.args.get('password')
    if not password:
        raise TracError('Password cannot be empty.')

    if password != req.args.get('password_confirm'):
        raise TracError('The passwords must match.')

    mgr.set_password(user, password)

    db = env.get_db_cnx()
    cursor = db.cursor()
    cursor.execute("SELECT count(*) FROM session "
                   "WHERE sid=%s AND authenticated=1",
                   (user,))
    exists, = cursor.fetchone()
    if not exists:
        cursor.execute("INSERT INTO session "
                       "(sid, authenticated, last_visit) "
                       "VALUES (%s, 1, 0)",
                       (user,))

    for key in ('name', 'email'):
        value = req.args.get(key)
        if not value:
            continue
        cursor.execute("UPDATE session_attribute SET value=%s "
                       "WHERE name=%s AND sid=%s AND authenticated=1",
                       (value, key, user))
        if not cursor.rowcount:
            cursor.execute("INSERT INTO session_attribute "
                           "(sid,authenticated,name,value) "
                           "VALUES (%s,1,%s,%s)",
                           (user, key, value))
    db.commit()
예제 #6
0
def _create_user(req, env, check_permissions=True):
    mgr = AccountManager(env)

    user = req.args.get('user')
    name = req.args.get('name')
    email = req.args.get('email')
    acctmgr = {'username' : user,
               'name' : name,
               'email' : email,
              }
    error = TracError('')
    error.acctmgr = acctmgr
    if not user:
        error.message = 'Username cannot be empty.'
        raise error

    if mgr.has_user(user):
        error.message = 'Another account with that name already exists.'
        raise error

    if check_permissions:
        # disallow registration of accounts which have existing permissions
        permission_system = perm.PermissionSystem(env)
        if permission_system.get_user_permissions(user) != \
           permission_system.get_user_permissions('authenticated'):
            error.message = 'Another account with that name already exists.'
            raise error

    password = req.args.get('password')
    if not password:
        error.message = 'Password cannot be empty.'
        raise error

    if password != req.args.get('password_confirm'):
        error.message = 'The passwords must match.'
        raise error

    if not email:
        error.message = 'You must provide an Email';
        raise error

    try:
        mgr.set_password(user, password)
    except TracError, e:
        e.acctmge = acctmgr
        raise e