Пример #1
0
def access():
    """Access."""
    try:
        mail = mail_cookie_check_mail_activation(request.values['mailcookie'])

        u = User.query.filter(User.email == mail).one()
        u.note = 1
        try:
            db.session.commit()
        except SQLAlchemyError:
            db.session.rollback()
            flash(_('Authorization failled.'), 'error')
            redirect('/')

        if current_user.is_authenticated():
            current_user.reload()
            flash(_('Your email address has been validated'), 'success')
        else:
            UserInfo(u.id).reload()
            flash(
                _('Your email address has been validated, and you can '
                  'now proceed to sign-in.'), 'success')
    except Exception:
        current_app.logger.exception("Authorization failed.")
        flash(_('The authorization token is invalid.'), 'error')
    return redirect('/')
Пример #2
0
def access():
    """Access."""
    try:
        mail = mail_cookie_check_mail_activation(request.values['mailcookie'])

        u = User.query.filter(User.email == mail).one()
        u.note = 1
        try:
            db.session.commit()
        except SQLAlchemyError:
            db.session.rollback()
            flash(_('Authorization failled.'), 'error')
            redirect('/')

        if current_user.is_authenticated():
            current_user.reload()
            flash(_('Your email address has been validated'), 'success')
        else:
            UserInfo(u.id).reload()
            flash(
                _('Your email address has been validated, and you can '
                  'now proceed to sign-in.'),
                'success'
            )
    except Exception:
        current_app.logger.exception("Authorization failed.")
        flash(_('The authorization token is invalid.'), 'error')
    return redirect('/')
Пример #3
0
def access():
    try:
        mail = mail_cookie_check_mail_activation(request.values['mailcookie'])
        User.query.filter(User.email == mail).one().note = 1
        try:
            db.session.commit()
        except:
            db.session.rollback()
            flash(_('Authorization failled.'), 'error')
        flash(
            _('Your email address has been validated, and you can now proceed '
              'to  sign-in.'),
            'success'
        )
    except:
        flash(_('The authorization token is invalid.'), 'error')
    return redirect('/')
Пример #4
0
def access():
    try:
        mail = mail_cookie_check_mail_activation(request.values['mailcookie'])
        User.query.filter(User.email == mail).one().note = 1
        try:
            db.session.commit()
        except:
            db.session.rollback()
            flash(_('Authorization failled.'), 'error')
        flash(
            _('Your email address has been validated, and you can now proceed '
              'to  sign-in.'),
            'success'
        )
    except:
        current_app.logger.exception("Authorization failed.")
        flash(_('The authorization token is invalid.'), 'error')
    return redirect('/')
Пример #5
0
 def access(self, req, form):
     args = wash_urlargd(form, {'mailcookie' : (str, '')})
     _ = gettext_set_language(args['ln'])
     title = _("Mail Cookie Service")
     try:
         kind = mail_cookie_retrieve_kind(args['mailcookie'])
         if kind == 'pw_reset':
             redirect_to_url(req, '%s/youraccount/resetpassword?k=%s&ln=%s' % (CFG_SITE_SECURE_URL, args['mailcookie'], args['ln']))
         elif kind == 'role':
             uid = webuser.getUid(req)
             try:
                 (role_name, expiration) = mail_cookie_check_role(args['mailcookie'], uid)
             except InvenioWebAccessMailCookieDeletedError:
                 return page(title=_("Role authorization request"), req=req, body=_("This request for an authorization has already been authorized."), uid=webuser.getUid(req), navmenuid='youraccount', language=args['ln'], secure_page_p=1)
             return page(title=title,
             body=webaccount.perform_back(
                 _("You have successfully obtained an authorization as %(x_role)s! "
                 "This authorization will last until %(x_expiration)s and until "
                 "you close your browser if you are a guest user.") %
                 {'x_role' : '<strong>%s</strong>' % role_name,
                  'x_expiration' : '<em>%s</em>' % expiration.strftime("%Y-%m-%d %H:%M:%S")},
                 '/youraccount/display?ln=%s' % args['ln'], _('login'), args['ln']),
             req=req,
             uid=webuser.getUid(req),
             language=args['ln'],
             lastupdated='',
             navmenuid='youraccount',
             secure_page_p=1)
         elif kind == 'mail_activation':
             try:
                 email = mail_cookie_check_mail_activation(args['mailcookie'])
                 if not email:
                     raise StandardError
                 webuser.confirm_email(email)
                 body = "<p>" + _("You have confirmed the validity of your email"
                     " address!") + "</p>"
                 if CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS == 1:
                     body += "<p>" + _("Please, wait for the administrator to "
                         "enable your account.") + "</p>"
                 else:
                     uid = webuser.update_Uid(req, email)
                     body += "<p>" + _("You can now go to %(x_url_open)syour account page%(x_url_close)s.") % {'x_url_open' : '<a href="/youraccount/display?ln=%s">' % args['ln'], 'x_url_close' : '</a>'} + "</p>"
                 return page(title=_("Email address successfully activated"),
                 body=body, req=req, language=args['ln'], uid=webuser.getUid(req), lastupdated='', navmenuid='youraccount', secure_page_p=1)
             except InvenioWebAccessMailCookieDeletedError:
                 body = "<p>" + _("You have already confirmed the validity of your email address!") + "</p>"
                 if CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS == 1:
                     body += "<p>" + _("Please, wait for the administrator to "
                         "enable your account.") + "</p>"
                 else:
                     body += "<p>" + _("You can now go to %(x_url_open)syour account page%(x_url_close)s.") % {'x_url_open' : '<a href="/youraccount/display?ln=%s">' % args['ln'], 'x_url_close' : '</a>'} + "</p>"
                 return page(title=_("Email address successfully activated"),
                     body=body, req=req, language=args['ln'], uid=webuser.getUid(req), lastupdated='', navmenuid='youraccount', secure_page_p=1)
             return webuser.page_not_authorized(req, "../youraccount/access",
                 text=_("This request for confirmation of an email "
                 "address is not valid or"
                 " is expired."), navmenuid='youraccount')
     except InvenioWebAccessMailCookieError:
         return webuser.page_not_authorized(req, "../youraccount/access",
             text=_("This request for an authorization is not valid or"
             " is expired."), navmenuid='youraccount')