Commit 95f9ad24 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Loggin configuration move in models/auth.py

parent 5acbc123
......@@ -61,6 +61,7 @@
'End Date': 'Date de fin',
'enter a number between %(min)g and %(max)g': 'enter a number between %(min)g and %(max)g',
'enter an integer between %(min)g and %(max)g': 'enter an integer between %(min)g and %(max)g',
'enter date as %(format)s': 'enter date as %(format)s',
'Event': 'Evènement',
'Event category': 'Event category',
'events': 'évènements',
......@@ -182,6 +183,7 @@
'Start': 'Début',
'start': 'début',
'Start Date': 'Date de début',
'Start_Date': 'Start_Date',
'startswith': 'startswith',
'Store': 'Store',
'Tables': 'Tables',
......
......@@ -4,61 +4,19 @@
setup the connection to the databases
"""
from gluon.tools import Auth
DB_MYSQL = 'mysql://GesProd:Prod_CPPM@maretude.in2p3.fr/TrackTeams'
# constant defining the different roles
ID_ADMIN, ADMIN, DEF_ADMIN = 1, 'admin', 'administrators, team leader,...'
ID_USER, USER, DEF_USER = 2, 'user', 'project leader,...'
# database migration flag
MIGRATE = False
#
# connect to the database
#
# try:
# db = DAL(DB_MYSQL, migrate_enabled=MIGRATE, pool_size=10)
# except:
# raise HTTP(500, T("Can't access the MySQL database !!!"))
db = DAL('sqlite://storage.sqlite', migrate_enabled=MIGRATE)
#
# User logging
# Approval is required for newly registered users
#
auth = Auth(db, hmac_key=Auth.get_or_create_key())
auth.define_tables(migrate=MIGRATE)
auth.settings.create_user_groups = False
auth.settings.mailer = None
auth.settings.registration_requires_approval = True
auth.settings.registration_requires_verification = False
auth.settings.remember_me_form = False
auth.settings.reset_password_requires_verification = True
# after registration go to the login page
auth.settings.register_next = URL('user', args='login')
# create user and admin groups
if not db(db.auth_group.id).count():
db.auth_group.insert(id=ID_ADMIN, role=ADMIN, description=T(DEF_ADMIN))
db.auth_group.insert(id=ID_USER, role=USER, description=T(DEF_USER))
# Newly registered users go in the user group
auth.settings.everybody_group_id = ID_USER
# The first user is auto approved and get all privilege (admin)
if not db(db.auth_user.id).count():
auth.settings.everybody_group_id = ID_ADMIN
auth.settings.registration_requires_approval = False
# tune authentication fields for the extJS interface
db.auth_user.registration_key.readable = True
db.auth_user.registration_key.writable = True
db.auth_membership.user_id.label = 'User'
db.auth_membership.group_id.label = 'Group'
# connection to the database
try:
db = DAL(DB_MYSQL, migrate_enabled=MIGRATE, pool_size=10)
except:
raise HTTP(500, T("Can't access the MySQL database !!!"))
db.auth_membership.user_id.requires = \
IS_IN_DB(db, 'auth_user.last_name')
# db = DAL('sqlite://storage.sqlite', migrate_enabled=MIGRATE)
\ No newline at end of file
# -*- coding: utf-8 -*-
""" auth
activate the identification procedure
"""
from gluon.tools import Auth
#
# User logging
# Approval is required for newly registered users
#
auth = Auth(db, hmac_key=Auth.get_or_create_key())
auth.define_tables(migrate=MIGRATE)
auth.settings.create_user_groups = False
auth.settings.mailer = None
auth.settings.registration_requires_approval = True
auth.settings.registration_requires_verification = False
auth.settings.remember_me_form = False
auth.settings.reset_password_requires_verification = True
# after registration go to the login page
auth.settings.register_next = URL('user', args='login')
# create user and admin groups
if not db(db.auth_group.id).count():
db.auth_group.insert(id=ID_ADMIN, role=ADMIN, description=T(DEF_ADMIN))
db.auth_group.insert(id=ID_USER, role=USER, description=T(DEF_USER))
# Newly registered users go in the user group
auth.settings.everybody_group_id = ID_USER
# The first user is auto approved and get all privilege (admin)
if not db(db.auth_user.id).count():
auth.settings.everybody_group_id = ID_ADMIN
auth.settings.registration_requires_approval = False
# tune authentication fields for the extJS interface
db.auth_user.registration_key.readable = True
db.auth_user.registration_key.writable = True
db.auth_membership.user_id.label = 'User'
db.auth_membership.group_id.label = 'Group'
db.auth_membership.user_id.requires = \
IS_IN_DB(db, 'auth_user.last_name')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment