# ------------------------------------------------------------------------- from gluon.tools import Auth, Service, PluginManager # host names must be a list of allowed host names (glob syntax allowed) auth = Auth(db, host_names=myconf.get('host.names')) service = Service() plugins = PluginManager() # ------------------------------------------------------------------------- # create all tables needed by auth if not custom tables # ------------------------------------------------------------------------- auth.define_tables(username=False, signature=False, migrate=0) from gluon.contrib.login_methods.email_auth import email_auth auth.settings.login_methods.append( email_auth("mail.etecsa.cu:587", "@etecsa.cu")) # ------------------------------------------------------------------------- # configure email # ------------------------------------------------------------------------- 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 # -------------------------------------------------------------------------
from gluon import current current.auth = auth current.db = db auth.settings.formstyle = 'bootstrap3_inline' #Active directory UPR from gluon.contrib.login_methods.ldap_auth import ldap_auth auth.settings.login_methods.append(ldap_auth(mode='ad', server=myconf.take('ad.server'), base_dn=myconf.take('ad.base_dn'), manage_user=True, user_firstname_attrib='cn:1', user_lastname_attrib='cn:2', user_mail_attrib='mail', db=db)) #Gmail auth from gluon.contrib.login_methods.email_auth import email_auth auth.settings.login_methods.append( email_auth("smtp.gmail.com:587", "@gmail.com ")) #Facebook id and key ''' client_id = "" client_secret = "" auth_url = "" token_url = "" from gluon.contrib.login_methods.oauth20_account import OAuthAccount auth.settings.login_form=OAuthAccount(client_id, client_secret, auth_url, token_url) ''' db._common_fields.append(auth.signature) # -------------------------------------------------------------------------
#from gluon.contrib.login_methods.gae_google_account import GaeGoogleAccount from gluon.tools import * auth = Auth(globals(), db) auth.define_tables() auth.settings.create_user_groups = False auth.settings.actions_disabled = ['register', 'request_reset_password'] auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = False auth.settings.register_next = URL (a = request.application, c = 'default', f = 'register') auth.settings.login_next = URL (scheme = 'http', a = request.application, c = 'default', f = 'index.html') auth.settings.login_methods.append( email_auth("smtp.gmail.com:587", "@gmail.com")) #auth.settings.login_form = GaeGoogleAccount () try: admin_role = auth.id_group ("Administrator") dev_role = auth.id_group ("Developer") auth_role = auth.id_group ("Authenticated") writer_role = auth.id_group ("Writer") editor_role = auth.id_group ("Editor") except: admin_role = None dev_role = None auth_role = None writer_role = None editor_role = None
from gluon.tools import Auth from gluon.contrib.login_methods.email_auth import email_auth db = DAL('sqlite://storage.sqlite') auth = Auth(db) auth.define_tables() auth.settings.login_methods.append( email_auth('smtp.gmail.com:465', '@ucsc.com'))
from gluon.tools import Auth, Crud from gluon.contrib.login_methods.email_auth import email_auth import datetime db = DAL('sqlite://storage.sqlite') crud=Crud(db) auth = Auth(db) auth.define_tables() auth.settings.login_methods.append(email_auth('smtp.gmail.com:465', '@ucsc.com')) # Hey I'm throwing out some ideas for tables I think we could use, feel free to make any changes, # I know there should be some more restrictions on the fields. # DISH # UCSC DH site lists nutritive restrictions on each dish, so that is something we could incorporate. # We could also implement a rating system on a dish-by-dish basis, but I think that would be overcomplicated, # and our users will already know what foods they like/dislike, but it's an option. # I was thinking instead of a table for menus, our app would just collect the dishes of the appropriate # DH, date, and meal, rather than selecting all the dishes for each DH/date/meal, which would be daunting. # Also, the UCSC DH site (http://nutrition.sa.ucsc.edu/location.asp) lists menu plans like 12 days in advance, # so an hour every couple weeks is probably all it would take to keep the app current. db.define_table( 'dish', Field('name', 'string'), Field('DH', 'string', requires=IS_NOT_EMPTY()), #cowell, crown, porter, eight, nine Field('date_served', 'date', default=datetime.datetime(2014, 12, 16)), Field('meal', 'string', requires=IS_NOT_EMPTY()) #breakfast, lunch, dinner ) # POSTS db.define_table('posts', Field('dh_name', 'string', required = True),
from gluon.tools import Mail mail_iua=Mail() mail_iua.settings.server = settings.email_server mail_iua.settings.sender = settings.iua_email_sender mail_iua.settings.login = settings.iua_email_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 # Use miuandes as authentification from gluon.contrib.login_methods.email_auth import email_auth auth.settings.actions_disabled = ['change_password'] auth.settings.login_methods.append(email_auth("smtp.gmail.com:587", "@miuandes.cl")) specialties = { 0: 'Industrial', 1: 'Obras Civiles', 2: 'Eléctrica', 3: 'Ciencia de la Computación' } auth.settings.extra_fields[auth.settings.table_user_name] = [ Field('rut', type='string'), Field('specialty', type='integer', label='Especialidad', requires=IS_IN_SET(specialties))] ## create all tables needed by auth if not custom tables auth.define_tables() user_roles = {