Exemplo n.º 1
0
class PasswordResetForm(BaseForm):
    successmsg = "Your password has been changed. You can now log in using your new password."
    fields = [
        PasswordField("pwd", "Password", REQUIRED),
        PasswordField("pwdconfirm", "Confirm password", REQUIRED)
    ]

    chained_validators = [
        formencode.validators.FieldsMatch('pwd', 'pwdconfirm')
    ]

    @classmethod
    def on_success(cls, request, values):
        try:
            UpdatePasswordProc(request, {
                'token': request.context.user.token,
                'pwd': values['pwd']
            })
        except DBMessage:
            raise  # HORROR HAPPENED
        request.session.flash(GenericSuccessMessage(cls.successmsg),
                              "generic_messages")
        return {
            'success': True,
            'redirect': request.fwd_url("admin_index"),
            'message': cls.successmsg
        }
Exemplo n.º 2
0
class PasswordResetForm(BaseForm):
    id = "pwdreset"
    label = "Password reset"
    action_label = "Save"
    fields = [
        PasswordField("pwd", "New Password", REQUIRED),
        PasswordField("pwdconfirm", "Confirm New Password", REQUIRED)
    ]
    chained_validators = [
        formencode.validators.FieldsMatch('pwd', 'pwdconfirm')
    ]

    @classmethod
    def on_success(self, request, values):
        try:
            UpdatePasswordProc(request, {
                'token': request.root.user.token,
                'pwd': values['pwd']
            })
        except DBMessage:
            raise  # HORROR HAPPENED
        request.session.flash(
            GenericSuccessMessage(
                "Your password has been changed. You can now log in using your new password."
            ), "generic_messages")
        request.fwd("website_user_profile")
Exemplo n.º 3
0
class SignupForm(BaseForm):
    id="signup"
    label = "Create account"
    action_label = "Create account"
    fields = [
        StringField("name", "Name", REQUIRED)
        , EmailField("email", "Email", HtmlAttrs(required = True, data_validation_url = '/signup/checkemail'))
        , PasswordField("pwd", "Password", REQUIRED)
        , PasswordField("pwdconfirm", "Retype password", REQUIRED)
        , CheckboxPostField("agreeTOS", 'I accept the <a class="link" target="_blank" href="/terms">terms of use</a> and <a class="link" target="_blank" href="/privacy">privacy statement</a>', REQUIRED)
    ]
    chained_validators = [formencode.validators.FieldsMatch('pwd', 'pwdconfirm')]
    @classmethod
    def on_success(cls, request, values):
        try:
            user = SignupProc(request, values)
        except DBMessage, e:
            if e.message == 'EMAIL_TAKEN':
                return {'success':False, 'errors':{'email': "Email already registered!"}}
            else:
                return {'success':False, 'errors':{'email': e.message}}
        return {'success':True, 'redirect':request.fwd_url("website_index_member")}
Exemplo n.º 4
0
class LoginForm(BaseForm):
    id="login"
    label ="Login"
    action_label = "Login"
    fields = [
        EmailField("email", None, attrs = Placeholder("Email", required = True))
        , PasswordField("pwd", None, attrs = Placeholder("Password", required = True))
    ]
    @classmethod
    def on_success(cls, request, values):
        try:
            user = LoginProc(request, values)
        except DBMessage, e:
            return {'success':False, 'errors':{'email': "Unknown email or password!"}}
        return {'success':True, 'redirect': request.fwd_url("website_index_member")}
Exemplo n.º 5
0
class JoinLoginForm(LoginForm):
    fields = [
        EmailField("email", "Email", REQUIRED),
        PasswordField("pwd", "Password", REQUIRED)
    ]

    @classmethod
    def on_success(cls, request, values):
        result = super(JoinLoginForm, cls).on_success(request, values)
        if result.get("success"):
            return {
                'success': True,
                'redirect': request.fwd_url("website_checkout_arbiter")
            }
        else:
            return result
Exemplo n.º 6
0
class LoginForm(BaseForm):
    label = "Login"
    action_label = "Login"
    fields = [
        EmailField("email", "Email", REQUIRED),
        PasswordField("pwd", "Password", REQUIRED)
    ]

    @classmethod
    def on_success(cls, request, values):
        try:
            user = AdminLoginProc(request, values)
        except DBMessage, e:
            msg = e.message
            if e.message == 'LOGIN_FAILED':
                msg = "Unknown email or password"
            return {'success': False, 'errors': {'email': msg}}
        else: