예제 #1
0
def login():
    from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
    auth = Auth(db_maestro)
    ## configure email
    mail = auth.settings.mailer
    mail.settings.server = 'smtp.gmail.com:587'
    mail.settings.sender = '*****@*****.**'
    mail.settings.login = '******'
    form = auth.login()
    return dict(form=form, formReset = auth.retrieve_password())
예제 #2
0
def navbar(auth_navbar, user_defaults=False):
    """ create a custom user navbar element (login, register...)

        see gluon/tools.py

        Args:
            user_defaults: Show user defaults link for logged in users if True

    """
    from gluon.tools import Auth
    bar = auth_navbar
    user = bar["user"]

    if not user:
        toggletext = current.T("Log In")
        toggle = A(toggletext,
                   _href="#",
                   _class="dropdown-toggle",
                   _rel="nofollow",
                   ** {"_data-toggle": "dropdown"})

        li_login = LI(A(current.T("Log In"), _class="icon-user",
                        _href=bar["login"], _rel="nofollow"))

        li_register = LI(A(current.T("Sign Up"), _class="icon-user-add",
                           _href=bar["register"], _rel="nofollow"))

        li_reset_pass = LI(A(
            current.T("Lost Password?"),
            _class="icon-mail",
            _href=bar["request_reset_password"],
            _rel="nofollow"
        ))

        auth = Auth(current.globalenv['db'])
        form = auth.login()

        # use https as target for the login form if it is enabled
        if current.settings.https_enabled:
            login_url = URL(
                "user",
                args=["login"],
                scheme="https",
                port=current.settings.https_port
            )
            form.custom.begin = XML(
                str(form.custom.begin).replace("#", login_url)
            )

        field_username = form.custom.widget.username
        field_username.update(_placeholder=T('Username'))
        field_password = form.custom.widget.password
        field_password.update(_placeholder=T('Password'))
        login_submit = form.custom.submit
        login_submit.update(**{"_data-w2p_disable_with": "%s" % T("Working")})

        li_login_form = LI(
            CAT(
                form.custom.begin,
                field_username,
                field_password,
                form.custom.widget.remember_me,
                LABEL(
                    T("Remember me"),
                    _for="auth_user_remember_me"
                ),
                form.custom.submit,
                form.custom.end
            )
        )

        dropdown = UL(
            li_reset_pass,
            li_register,
            LI('', _class="divider"),
            li_login,
            li_login_form,
            _class="dropdown-menu user-menu", _role="menu"
        )

        return LI(toggle, dropdown, _class="dropdown")

    else:
        toggletext = "%s %s" % (bar["prefix"], user)
        toggle = A(toggletext,
                   _href="#",
                   _class="dropdown-toggle",
                   _rel="nofollow",
                   ** {"_data-toggle": "dropdown"})
        li_profile = LI(A(current.T("Account Details"), _class="icon-user",
                        _href=bar["profile"], _rel="nofollow"))

        li_builds = LI(
            A(
                current.T("Your Builds"),
                _class="icon-picture",
                _href=URL("user_builds"),
                _rel="nofollow",
            )
        )

        li_password = LI(A(current.T("Password"), _class="icon-lock",
                           _href=bar["change_password"], _rel="nofollow"))

        if user_defaults:
            li_defaults = LI(
                A(current.T("Firmware Defaults"), _class="icon-wrench",
                  _href=URL("user_defaults"), _rel="nofollow"))
        else:
            li_defaults = ''

        li_logout = LI(A(current.T("Log Out"), _class="icon-login",
                       _href=bar["logout"], _rel="nofollow"))

        dropdown = UL(li_defaults,
                      li_builds,
                      li_profile,
                      li_password,
                      LI('', _class="divider"),
                      li_logout,
                      _class="dropdown-menu", _role="menu")

        return LI(toggle, dropdown, _class="dropdown user-menu")
예제 #3
0
파일: db.py 프로젝트: proj-tris/IT_PROJECT
## >>> 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)
## >>> for row in rows: print row.id, row.myfield
#########################################################################

## after defining tables, uncomment below to enable auditing
# auth.enable_record_versioning(db)
auth.login(next=URL('default','login_home'))
if auth.user is None:
    pass
else:
    db.define_table('text1',Field('email','string', default=auth.user.email ), Field('added', 'datetime', default=datetime.datetime.now()), Field('note', 'string'),Field('title', 'string'),Field('font', 'string'))
if auth.user is None:
    pass
else:
    db.define_table('notes_upload',Field('email','string', default=auth.user.email), Field('added', 'datetime', default=datetime.datetime.now()), Field('note', 'upload'))
auth.settings.login_next = URL('login_home')
if auth.user is None:
    pass
else:
    db.define_table('voice',Field('email','string',default=auth.user.email),Field('added','datetime',default=datetime.datetime.now()),Field('note','string'),Field('title','string'))
auth.settings.login_next=URL('login_home')    
예제 #4
0
파일: db.py 프로젝트: proj-tris/IT_PROJECT
auth.define_tables(username=False, signature=False)

## configure email
mail = auth.settings.mailer
mail.settings.server = "logging" or "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.register_next = URL(c="default", f="login_home")
auth.settings.register_next = URL("login_home")
auth.settings.logout_next = URL("index")
auth.login(next=URL("default", "login_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.rpx_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
예제 #5
0
파일: db.py 프로젝트: naruto0323/Tris-1
auth.define_tables(username=False, signature=False)

## configure email
mail = auth.settings.mailer
mail.settings.server = 'logging' or '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.register_next = URL(c='default', f='login_home')
auth.settings.register_next = URL('login_home')
auth.settings.logout_next = URL('index')
auth.login(next=URL('default', 'login_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.rpx_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