Example #1
0
            error_message = 'O e-mail deve ser @%s' % required_domain),
                IS_NOT_IN_DB(db, forca_auth.email, error_message='Este e-mail já está cadastrado')]
else:
    forca_auth.email.requires = \
            [IS_NOT_IN_DB(db, forca_auth.email, error_message='Este e-mail já está cadastrado')]

#auth settings
auth.settings.table_user = forca_auth
auth.settings.registration_requires_verification = True
auth.settings.registration_requires_approval = False
auth.settings.create_user_groups = False
auth.settings.register_next = URL(request.application, 'default', 'user/login')

auth.define_tables(migrate=False)

if not auth.id_group('Aluno'):
    auth.add_group('Aluno', 'Aluno')
if not auth.id_group('Professor'):
    auth.add_group('Professor', 'Professor')
if not auth.id_group('Admin'):
    auth.add_group('Admin', 'Administrador')


#definicao de categoria por email
def is_professor(form):
    email = form.vars.email
    if len(db(db.professores.email == email).select()) > 0:
        auth.add_membership(auth.id_group('Professor'), int(form.vars.id))
        prof_create(form.vars)
    else:
        if email == master_admin:
Example #2
0
            error_message = 'O e-mail deve ser @%s' % required_domain),
                IS_NOT_IN_DB(db, forca_auth.email, error_message='Este e-mail já está cadastrado')]
else:
    forca_auth.email.requires = \
            [IS_NOT_IN_DB(db, forca_auth.email, error_message='Este e-mail já está cadastrado')]

#auth settings
auth.settings.table_user = forca_auth
auth.settings.registration_requires_verification = True
auth.settings.registration_requires_approval = False
auth.settings.create_user_groups = False
auth.settings.register_next = URL(request.application, 'default', 'user/login')

auth.define_tables()

if not auth.id_group('Aluno'):
    auth.add_group('Aluno', 'Aluno')
if not auth.id_group('Professor'):
    auth.add_group('Professor', 'Professor')
if not auth.id_group('Admin'):
    auth.add_group('Admin', 'Administrador')

#definicao de categoria por email
def is_professor(form):
    email = form.vars.email
    if len(db(db.professores.email==email).select()) > 0:
        auth.add_membership(auth.id_group('Professor'), int(form.vars.id))
        prof_create(form.vars)
    else:
        if email == master_admin:
            auth.add_membership(auth.id_group('Admin'), int(form.vars.id))
Example #3
0
db.auth_group.description.requires = [IS_LENGTH(160,error_message='No puede tener mas de 160 caracteres.')]
db.auth_group.role.requires = [IS_LENGTH(20,error_message='No puede tener mas de 20 caracteres.')]
db.auth_user.password.requires = [IS_NOT_EMPTY(error_message='No puede estar vacio.')]

from gluon.tools import Mail
mail = Mail()
mail.settings.server = 'smtp.gmail.com:587'
mail.settings.sender = '*****@*****.**'
mail.settings.login = '******'
auth.settings.mailer = mail
## configure auth policy
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True
auth.settings.create_user_groups = False
auth.settings.everybody_group_id = auth.id_group('Proponente')
auth.settings.login_next=URL(r=request, c='default', f='home')

## if you need to use OpenID, Facebook, MySpace, Twitter, Linkedin, etc.
## register with janrain.com, write your domain:api_key in private/janrain.key
from gluon.contrib.login_methods.janrain_account import use_janrain
use_janrain(auth, filename='private/janrain.key')

auth.messages.submit_button = 'Enviar'
auth.messages.verify_password = '******'
auth.messages.new_password = '******'
auth.messages.old_password = '******'
auth.messages.password_changed = 'Contraseña cambiada'
auth.messages.retrieve_username = '******'
auth.messages.invalid_login = '******'
auth.messages.invalid_user = '******'
Example #4
0
File: db.py Project: manuggz/SIGESC
## create all tables needed by auth if not custom tables
auth.define_tables(username=True, signature=False)

## configure email
mail = auth.settings.mailer
mail.settings.server = 'logging' if request.is_local else 'smtp.gmail.com:587'
mail.settings.sender = '*****@*****.**'
mail.settings.login = '******'

## configure auth policy
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True
auth.settings.create_user_groups = False
auth.settings.everybody_group_id = auth.id_group('Proponente')
auth.settings.login_next=URL(r=request, c='default', f='vista_admin')

## if you need to use OpenID, Facebook, MySpace, Twitter, Linkedin, etc.
## register with janrain.com, write your domain:api_key in private/janrain.key
from gluon.contrib.login_methods.janrain_account import use_janrain
use_janrain(auth, filename='private/janrain.key')

#########################################################################
## Define your tables below (or better in another model file) for example
##
## >>> db.define_table('mytable',Field('myfield','string'))
##
## Fields can be 'string','text','password','integer','double','boolean'
##       'date','time','datetime','blob','upload', 'reference TABLENAME'
## There is an implicit 'id integer autoincrement' field
Example #5
0
crud, service, plugins = Crud(db), Service(), PluginManager()

## configure auth policy
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True

## configure email
mail=auth.settings.mailer
mail.settings.server = 'logging' or 'smtp.gmail.com:587'
mail.settings.sender = '*****@*****.**'
mail.settings.login = '******'

## init groups and permission
g_manager_id=auth.id_group('Manager') or auth.add_group('Manager','can access the manage action/page')
g_user_id=auth.id_group('User') or auth.add_group('User','can view and borrow')
g_admin_id=auth.id_group('Admin') or auth.add_group('Admin','everything')

auth.add_permission(g_manager_id,'access to manage')
auth.add_permission(g_manager_id,'access to borrow')

auth.add_permission(g_user_id,'access to borrow')

auth.add_permission(g_admin_id,'access to manage')
auth.add_permission(g_admin_id,'access to borrow')
auth.add_permission(g_admin_id,'access to admin')

rows = db(auth.settings.table_user.email == '*****@*****.**').select()
if rows:
    user_admin_id=rows.first().id
Example #6
0
                Field('id_inventario', db.inventario),
                Field('fecha_prestacion', 'datetime'),
                Field('fecha_devolucion', 'time'))

if (db(db.auth_group).isempty()):
    auth.add_group('admin', 'admin')
    auth.add_group('supervisor', 'supervisor')
    auth.add_group('user_basic', 'user_basic')

#Revisar esto
if not db().select(db.auth_user.ALL).first():
    id_user = db.auth_user.insert(
        username='******',
        password=db.auth_user.password.validate('admin')[0],
        email='*****@*****.**',
        first_name='admin',
        last_name='Administrator',
    )
    auth.del_membership(auth.id_group('user_basic'), id_user)
    auth.add_membership(auth.id_group('admin'), id_user)

    id_user = db.auth_user.insert(
        username='******',
        password=db.auth_user.password.validate('supervisor')[0],
        email='*****@*****.**',
        first_name='supervior',
        last_name='Supervisor',
    )
    auth.del_membership(auth.id_group('user_basic'), id_user)
    auth.add_membership(auth.id_group('supervisor'), id_user)
Example #7
0
File: db.py Project: paapu68/web2py
db.define_table('kurssi',
   Field('title', unique=True),
   Field('opettaja_id', 'reference opettaja'),
   format = '%(title)s')

db.define_table('kurssityon_nimi',
   Field('title'),
   Field('kurssi_id','reference kurssi'),
   Field('opettaja_id', 'reference opettaja'),
   format = '%(title)s')

db.define_table('kurssityo',
   Field('nimi_id','reference kurssityon_nimi'),
   Field('palautettu', 'upload'),
   Field('korjattu', 'upload',writable = auth.has_membership(auth.id_group('opettaja'))),
   Field('arvosana',writable = auth.has_membership(auth.id_group('opettaja'))),
   Field('kurssi_id', 'reference kurssi'),
   Field('opiskelija_id', 'reference opiskelija'),
   format=lambda r: '%s' \
       % (db.kurssityon_nimi[r.nimi_id].title)
   )

#db.tyo.title.requires = IS_NOT_IN_DB(db, db.tyo.title)
#db.post.image_id.requires = IS_IN_DB(db, db.image.id, '%(title)s')
#db.post.author.requires = IS_NOT_EMPTY()
#db.post.email.requires = IS_EMAIL()
#db.post.body.requires = IS_NOT_EMPTY()

#db.post.image_id.writable = db.post.image_id.readable = False
Example #8
0
File: db.py Project: ritces/SIGULAB
mail.settings.sender = myconf.get('smtp.sender')
mail.settings.login = myconf.get('smtp.login')
mail.settings.tls = myconf.get('smtp.tls') or False
mail.settings.ssl = myconf.get('smtp.ssl') or False

# -------------------------------------------------------------------------
# configure auth policy
# -------------------------------------------------------------------------
auth.settings.registration_requires_verification = False  #True
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True

# Evita crear grupos al registar
auth.settings.create_user_groups = None
# Grupo default registro - id cambia?
auth.settings.everybody_group_id = auth.id_group(role='Usuario Normal')

# Deshabilitar registro y otras paginas
#auth.settings.actions_disabled.append('register')
#auth.settings.actions_disabled.append('profile')
#auth.settings.actions_disabled.append('change_password')
auth.settings.actions_disabled.append('impersonate')
#auth.settings.actions_disabled.append('groups')
####################################################################

from gluon.tools import Crud

crud = Crud(db)

# -------------------------------------------------------------------------
# Define your tables below (or better in another model file) for example
Example #9
0
from gluon.tools import Auth
auth = Auth(db, hmac_key=Auth.get_or_create_key())

auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True

auth.define_tables ()

admin_role = auth.id_group ("Administrator")
if not admin_role:
    admin_role = auth.add_group ("Administrator", "System Administrator - can access & make changes to any data")

editor_role = -1
writer_role = -1

def require_logged_in (func):
    def wrapper (*args, **kwargs):
        if not auth.user:
            redirect (URL (r = request, c = 'default', f = 'user', args = ['login']))
        return func (*args, **kwargs)
    return wrapper

def require_logged_in_deprecated ():
    if not auth.user:
        redirect (URL (r = request, c = 'default', f = 'user', args = ['login']))

def require_role (role):
    def decorator (func):
        def wrapper (*args, **kwargs):
            if not auth.user:
Example #10
0
settings.mail.sender = settings.globals.email_sender
settings.mail.login = settings.globals.email_login
settings.mail.ssl = settings.globals.email_ssl

mail.settings.server = settings.mail.server
mail.settings.sender = settings.mail.sender
mail.settings.login = settings.mail.login


# settings.auth
settings.auth.hmac_key = 'sha512:7a716c8b015b5caca119e195533717fe9a3095d67b3f97114e30256b27392977'    # before define_tables()

auth.define_tables(username=True)


if auth.id_group("admin"):
    settings.private.admingroup = auth.id_group("admin")
else:
    auth.add_group('admin', 'Node admins')

if auth.id_group("targets"):
    settings.private.admingroup = auth.id_group("targets")
else:
    auth.add_group('targets', 'Targets')

if auth.id_group("candelete"):
    settings.private.admingroup = auth.id_group("candelete")
else:
    auth.add_group('candelete', 'candelete')

settings.auth.mailer = mail                                    # for user email verification
Example #11
0
custom_auth_table.email.requires = [
    IS_EMAIL(error_message=auth.messages.invalid_email),
    IS_NOT_IN_DB(db, custom_auth_table.email)
]

## create all tables needed by auth if not custom tables
auth.define_tables()

## configure email
mail = auth.settings.mailer
mail.settings.server = 'smtp.gmail.com:587'
mail.settings.sender = '*****@*****.**'
mail.settings.login = '******'

## configure auth policy
generalAuth = auth.id_group(role="General")
if auth.id_group(role="General") <= 0:
    generalAuth = auth.add_group(role="General")
if auth.id_group(role="Admin") <= 0:
    adminAuth = auth.add_group(role="Admin")
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True
auth.settings.password_min_length = 5
##auth.settings.everybody_group_id = 5

## if you need to use OpenID, Facebook, MySpace, Twitter, Linkedin, etc.
## register with janrain.com, write your domain:api_key in private/janrain.key
from gluon.contrib.login_methods.rpx_account import use_janrain
use_janrain(auth, filename='private/janrain.key')
Example #12
0
File: auth.py Project: tyron/ForCA
forca_auth.password.requires = [IS_LENGTH(minsize=2, error_message="A senha deve ter pelo menos 2 caracteres"), CRYPT()]
forca_auth.email.requires = [
    IS_EMAIL(forced="inf\.ufrgs\.br", error_message="O e-mail deve ser @inf.ufrgs.br"),
    IS_NOT_IN_DB(db, forca_auth.email, error_message="Este e-mail já está cadastrado"),
]

# auth settings
auth.settings.table_user = forca_auth
auth.settings.registration_requires_verification = True
auth.settings.registration_requires_approval = False
auth.settings.create_user_groups = False
auth.settings.register_next = URL(request.application, "default", "user/login")

auth.define_tables()

if not auth.id_group("Aluno"):
    auth.add_group("Aluno", "Aluno do Instituto de Informática")
if not auth.id_group("Professor"):
    auth.add_group("Professor", "Professor do Instituto de Informática")
if not auth.id_group("Admin"):
    auth.add_group("Admin", "Administrador do sistema")

# definicao de categoria por email
def is_professor(form):
    email = form.vars.email
    if len(db(db.professores.email == email).select()) > 0:
        auth.add_membership(auth.id_group("Professor"), int(form.vars.id))
        prof_create(form.vars)
    else:
        auth.add_membership(auth.id_group("Aluno"), int(form.vars.id))
        aluno_create(form.vars)
Example #13
0
mail.settings.server = 'logging' if request.is_local else myconf.get(
    'smtp.server')
mail.settings.sender = myconf.get('smtp.sender')
mail.settings.login = myconf.get('smtp.login')
mail.settings.tls = myconf.get('smtp.tls') or False
mail.settings.ssl = myconf.get('smtp.ssl') or False

# -------------------------------------------------------------------------
# configure auth policy
# -------------------------------------------------------------------------
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True

auth.settings.create_user_groups = False
auth.settings.everybody_group_id = auth.id_group(role='user')

# -------------------------------------------------------------------------
# Define your tables below (or better in another model file) for example
#
# >>> db.define_table('mytable', Field('myfield', 'string'))
#
# Fields can be 'string','text','password','integer','double','boolean'
#       'date','time','datetime','blob','upload', 'reference TABLENAME'
# There is an implicit 'id integer autoincrement' field
# Consult manual for more options, validators, etc.
#
# More API examples for controllers:
#
# >>> db.mytable.insert(myfield='value')
# >>> rows = db(db.mytable.myfield == 'value').select(db.mytable.ALL)
Example #14
0
mail = auth.settings.mailer
mail.settings.server = 'logging' if request.is_local else myconf.get('smtp.server')
mail.settings.sender = myconf.get('smtp.sender')
mail.settings.login = myconf.get('smtp.login')
mail.settings.tls = myconf.get('smtp.tls') or False
mail.settings.ssl = myconf.get('smtp.ssl') or False

# -------------------------------------------------------------------------
# configure auth policy
# -------------------------------------------------------------------------
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True

auth.settings.create_user_groups = False
auth.settings.everybody_group_id = auth.id_group(role='user')

# -------------------------------------------------------------------------
# Define your tables below (or better in another model file) for example
#
# >>> db.define_table('mytable', Field('myfield', 'string'))
#
# Fields can be 'string','text','password','integer','double','boolean'
#       'date','time','datetime','blob','upload', 'reference TABLENAME'
# There is an implicit 'id integer autoincrement' field
# Consult manual for more options, validators, etc.
#
# More API examples for controllers:
#
# >>> db.mytable.insert(myfield='value')
# >>> rows = db(db.mytable.myfield == 'value').select(db.mytable.ALL)
Example #15
0
              error_message=T('Password length must be at least 5'))]
custom_auth_table.email.requires = [
  IS_EMAIL(error_message=auth.messages.invalid_email),
  IS_NOT_IN_DB(db, custom_auth_table.email)]

## create all tables needed by auth if not custom tables
auth.define_tables()

## configure email
mail=auth.settings.mailer
mail.settings.server = 'smtp.gmail.com:587'
mail.settings.sender = '*****@*****.**'
mail.settings.login = '******'

## configure auth policy
generalAuth = auth.id_group(role="General");
if auth.id_group(role="General")<=0:
    generalAuth = auth.add_group(role="General")
if auth.id_group(role="Admin")<=0:
    adminAuth = auth.add_group(role="Admin")
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True
auth.settings.password_min_length = 5
##auth.settings.everybody_group_id = 5

## if you need to use OpenID, Facebook, MySpace, Twitter, Linkedin, etc.
## register with janrain.com, write your domain:api_key in private/janrain.key
from gluon.contrib.login_methods.rpx_account import use_janrain
use_janrain(auth,filename='private/janrain.key')