def set_session(sess, man): sess.man_id = man.id sess.man_name = man.name
# confirm - подтверждение по почте полученоdef greet_conf(): key = request.args(0) if not key: return dict(h = T('Empty key')) rec = db(db.man_keys.temp_key == key).select().first() if not rec: return dict(h = T('Key not found')) man = db.men[ rec.man_id ] del db.man_keys[ rec.id ] if not man: return dict(h = T('Man not found')) set_session(session, man) #return dict(h = CAT(T('Welcome'),', ', man.name)) redirect(URL('default','index'))
def mail_greet(man, req): from gluon.tools import Mail import random import string key = ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for x in range(40)) # запомним ключ посланный - только его принимаем db(db.man_keys.man_id == man.id ).delete() db.man_keys.insert( man_id = man.id, temp_key = key ) url = URL('man', 'greet_conf', args=[key], scheme=True, host=True) #context = dict( key = key, man = man.name, url = url ) #mess = response.render('man/email_greet.html', context) mess = CAT( H4(T('Hi'), ', ',man.name, '!'), BR(), T('You or someone request a re-greeting on %s') % req.env.http_host, BR(), #T('You or someone request a re-greeting on %s') % 'LITE.cash/bets', BR(), T('If that not you simple ignore that letter.'),B(), T('or'),BR(), T('For restore your greet on our site click'), ' ', A(H1(B(T('re-greeting url'))), _href=url), ) h = CAT(P(T('A letter sent to [%s]. Check your email and spam (junk) folder') % man.email))
if req.is_local: h += DIV(mess) else: from gluon.tools import Mail mail = Mail() mail.settings.server = settings.email_server mail.settings.sender = settings.email_sender mail.settings.login = settings.email_login mail.send( to = man.email, subject = T('Restore access to BETS'), message = '<html>%s</html>' % mess ) return h
def greet(): res = '' if session.man_id: return dict( h = DIV(XML(T('Use %s menu first') % A(T('Forget Me'), _href=URL('man', 'forget'))))) form = FORM(LABEL(T('Input Your Email')), INPUT(_name='em', requires=IS_EMAIL()), INPUT(_type='submit', _class='btn btn-' + CLRS.btn)) if form.accepts(request, session, keepvalues=True): man = db(db.men.email == form.vars.em).select().first() if man: response.flash = 'Email with access key send to Your. Check email and spam folder' res = mail_greet(man, request) else: form.errors.em = 'That email not metting' response.flash = T('That email not metting, please to Meet first') elif form.errors: response.flash = '' else: response.flash = 'please fill the form' h = DIV(T('For to restore Dating enter your email address and we will send you the key'), '. ', #T('If that email not known for as'), ' ', #A(T('to Meet'), _href=URL('man','meet')), ' ', T('first.'), form, res, _class='inv') return dict( h = h )
def forget(): #return dict( h = (T('Sorry, email is busy'))) session.man_id = session.man_name = session.man = None redirect(URL('man', 'meet'))def form_accs_validate(f): if db((db.man_accs.man_id == f.vars.man_id) & (db.man_accs.cash_id == f.vars.cash_id)).select().first(): f.errors.cash_id = T('Aready exist') response.flash = 'form has errors'
Anyone who previously logged in with a Google account will continue to be able to log in via the Google+ provider. Note, by default, users without a Google+ account will be prompted to create one. However, Janrain provides an option to disable that requirement (which you will be presented with during step 1 above).
Note, depending on your version of web2py, you might also need to update the web2py Janrain code. The latest file is /gluon/contrib/login_methods/janrain_account.py, but there is also an updated rpx_account.py for backward compatibility (if you don't want to change your import statement.
Anthony