Exemplo n.º 1
0
def register():
    method = request.env.request_method
    if (method == 'GET'):
        return dict();
    if (method == 'POST'):
        success = True
        errorFields = []

        name = request.post_vars.name
        login = request.post_vars.login
        password = request.post_vars.password
        email = request.post_vars.email

        if (name == ""):
            success = False
            errorFields.append("name")
        if ((login == "") | (UserDao.userWithLoginExists(login))):
            success = False
            errorFields.append("login")
        if ((not re.match("[^@]+@[^@]+\.[^@]+", email)) | (UserDao.userWithEmailExists(email))):
            success = False
            errorFields.append("email")
        if (password == ""):
            success = False
            errorFields.append("password")

        if (success):
            db.user.insert(name = name, login = login, password = password, mail = email)

        return dict(success = success, errorFields = errorFields)
Exemplo n.º 2
0
def tryToLogin(email, password):
    user = UserDao.authorizeByEmailOrLogin(email, password)
    if (hasattr(user, 'id')):
        current.response.cookies['userid'] = user.id
        current.response.cookies['userid']['path'] = '/'
        current.response.cookies['userid']['expires'] = 3600
        current.response.cookies['username'] = user.name
        current.response.cookies['username']['path'] = '/'
        current.response.cookies['username']['expires'] = 3600
        return True
    else:
        return False
Exemplo n.º 3
0
def index():
    rows = UserDao.getAllUsers();
    return dict(users = rows)
Exemplo n.º 4
0
def index():
    rows = UserDao.getProjectsForUser(current.userId)
    return dict(projects = rows)