From 04a7b7a62028ef766161d3c8ea9f7338cd6606af Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 31 Dec 2016 23:21:15 +0000 Subject: [PATCH] Fix activation form to work with Foundation setup --- blocks/ORB/Login.pm | 74 ++++++++++++++-------------- lang/en/login.lang | 22 +++++---- templates/default/login/act_form.tem | 19 +++++++ 3 files changed, 68 insertions(+), 47 deletions(-) create mode 100644 templates/default/login/act_form.tem diff --git a/blocks/ORB/Login.pm b/blocks/ORB/Login.pm index 6088220..b746ba6 100755 --- a/blocks/ORB/Login.pm +++ b/blocks/ORB/Login.pm @@ -559,13 +559,13 @@ sub _validate_actcode { # Check that the code has been provided and contains allowed characters ($args -> {"actcode"}, $error) = $self -> validate_string("actcode", {"required" => 1, - "nicename" => "{L_LOGIN_ACTCODE}", + "nicename" => "{L_LOGIN_ACTIVATE_CODE}", "minlen" => 64, "maxlen" => 64, "formattest" => '^[a-zA-Z0-9]+$', "formatdesc" => "{L_LOGIN_ERR_BADACTCHAR}"}); # Bomb out at this point if the code is not valid. - return $self -> {"template"} -> load_template("error/error.tem", { "%(message)s" => "{L_LOGIN_ACTFAILED}", + return $self -> {"template"} -> load_template("error/error.tem", { "%(message)s" => "{L_LOGIN_ACTIVATE_FAILED}", "%(reason)s" => $error}) if($error); @@ -574,7 +574,7 @@ sub _validate_actcode { # we don't actually know which user is being activated until the actcode lookup is done. And generally, if # an act code has been set, the authmethod supports activation anyway! my $user = $self -> {"session"} -> {"auth"} -> activate_user($args -> {"actcode"}); - return ($self -> {"template"} -> load_template("error/error.tem", { "%(message)s" => "{L_LOGIN_ACTFAILED}", + return ($self -> {"template"} -> load_template("error/error.tem", { "%(message)s" => "{L_LOGIN_ACTIVATE_FAILED}", "%(reason)s" => "{L_LOGIN_ERR_BADCODE}"}), $args) unless($user); @@ -815,6 +815,28 @@ sub _generate_signup_form { } +## @method private @ generate_actcode_form($error) +# Generate a form through which the user may specify an activation code. +# +# @param error A string containing errors related to activating, or undef. +# @return An array of two values: the page title string, the code form +sub _generate_actcode_form { + my $self = shift; + my $error = shift; + + # Wrap the error message in a message box if we have one. + $error = $self -> {"template"} -> load_template("error/error_box.tem", {"%(message)s" => $error}) + if($error); + + return ("{L_LOGIN_TITLE}", + $self -> {"template"} -> load_template("login/act_form.tem", {"%(error)s" => $error, + "%(target)s" => $self -> build_url("block" => "login"), + "%(url-resend)s" => $self -> build_url("block" => "login", "pathinfo" => [ "resend" ]),}), + $self -> {"template"} -> load_template("login/extrahead.tem"), + $self -> {"template"} -> load_template("login/extrajs.tem")); +} + + ## @method private @ generate_passchange_form($error) # Generate a form through which the user can change their password, used to # support forced password changes. @@ -849,26 +871,6 @@ sub _generate_passchange_form { } -## @method private @ generate_actcode_form($error) -# Generate a form through which the user may specify an activation code. -# -# @param error A string containing errors related to activating, or undef. -# @return An array of two values: the page title string, the code form -sub _generate_actcode_form { - my $self = shift; - my $error = shift; - - # Wrap the error message in a message box if we have one. - $error = $self -> {"template"} -> load_template("error/error_box.tem", {"%(message)s" => $error}) - if($error); - - return ("{L_LOGIN_TITLE}", - $self -> {"template"} -> load_template("login/act_form.tem", {"%(error)s" => $error, - "%(target)s" => $self -> build_url("block" => "login"), - "%(url-resend)s" => $self -> build_url("block" => "login", "pathinfo" => [ "resend" ]),})); -} - - ## @method private @ generate_recover_form($error) # Generate a form through which the user may recover their account details. # @@ -988,20 +990,18 @@ sub _generate_signedout { sub _generate_activated { my $self = shift; - my $target = $self -> build_url(block => "login", - pathinfo => []); + my $url = $self -> build_url(block => "login", + pathinfo => []); - return ("{L_LOGIN_ACT_DONETITLE}", - $self -> message_box("{L_LOGIN_ACT_DONETITLE}", - "security", - "{L_LOGIN_ACT_SUMMARY}", - $self -> {"template"} -> replace_langvar("LOGIN_ACT_LONGDESC", - {"%(url-login)s" => $self -> build_url("block" => "login")}), - undef, - "logincore", - [ {"message" => "{L_LOGIN_LOGIN}", - "colour" => "blue", - "action" => "location.href='$target'"} ])); + return ("{L_LOGIN_ACTIVATE_DONETITLE}", + $self -> message_box(title => "{L_LOGIN_ACTIVATE_DONETITLE}", + type => "account", + summary => "{L_LOGIN_ACTIVATE_SUMMARY}", + message => $self -> {"template"} -> replace_langvar("LOGIN_ACTIVATE_MESSAGE", + {"%(url-login)s" => $self -> build_url("block" => "login")}), + buttons => [ {"message" => "{L_LOGIN_LOGIN}", + "colour" => "standard", + "href" => "$url"} ])); } @@ -1022,7 +1022,7 @@ sub _generate_signedup { summary => "{L_LOGIN_SIGNUP_SUMMARY}", message => "{L_LOGIN_SIGNUP_MESSAGE}", buttons => [ {"message" => "{L_LOGIN_ACTIVATE}", - "colour" => "warning", + "colour" => "standard", "href" => $url} ])); } diff --git a/lang/en/login.lang b/lang/en/login.lang index be49782..9f98339 100755 --- a/lang/en/login.lang +++ b/lang/en/login.lang @@ -54,18 +54,19 @@ LOGIN_SIGNUP_ALTACT = Alternatively, enter the following code in the account LOGIN_SIGNUP_ENJOY = Thank you for registering! # Activation related -LOGIN_ACTCODE = Activation code -LOGIN_ACTFAILED = User account activation failed -LOGIN_ACTFORM = Activate account -LOGIN_ACTINTRO = Please enter your 64 character activation code here. -LOGIN_ACTIVATE = Activate account -LOGIN_ERR_BADACTCHAR = Activation codes may only contain alphanumeric characters. -LOGIN_ERR_BADCODE = The provided activation code is invalid: either your account is already active, or you entered the code incorrectly. Note that the code is case sensitive - upper and lower case characters are treated differently. Please check you entered the code correctly. +LOGIN_ACTIVATE_CODE = Activation code +LOGIN_ACTIVATE_FAILED = User account activation failed +LOGIN_ACTIVATE_FORM = Activate account +LOGIN_ACTIVATE_INTRO = Please enter your 64 character activation code here. +LOGIN_ACTIVATE_RESEND = Resend activation code +LOGIN_ACTIVATE = Activate account +LOGIN_ERR_BADACTCHAR = Activation codes may only contain alphanumeric characters. +LOGIN_ERR_BADCODE = The provided activation code is invalid: either your account is already active, or you entered the code incorrectly. Note that the code is case sensitive - upper and lower case characters are treated differently. Please check you entered the code correctly. # Activation done -LOGIN_ACT_DONETITLE = Account activated -LOGIN_ACT_SUMMARY = Activation successful! -LOGIN_ACT_LONGDESC = Your new account has been acivated, and you can now sign in using your username and the password emailed to you. +LOGIN_ACTIVATE_DONETITLE = Account activated +LOGIN_ACTIVATE_SUMMARY = Activation successful! +LOGIN_ACTIVATE_MESSAGE = Your new account has been acivated, and you can now sign in using your username and the password emailed to you. # Recovery related LOGIN_RECFORM = Recover account details @@ -116,6 +117,7 @@ LOGIN_RESEND_FAILED = Activation code resend failed LOGIN_RESEND_DONETITLE = Activation code resent LOGIN_RESEND_SUMMARY = Resend successful! LOGIN_RESEND_LONGDESC = A new password and an activation link have been send to your email address.

Please check your email for a message with the subject 'Your {V_[sitename]} activation code' and follow the instructions it contains to activate your account. + # Force password change LOGIN_PASSCHANGE = Change password LOGIN_FORCECHANGE_INTRO = Before you continue, please choose a new password to set for your account. diff --git a/templates/default/login/act_form.tem b/templates/default/login/act_form.tem new file mode 100644 index 0000000..49b2664 --- /dev/null +++ b/templates/default/login/act_form.tem @@ -0,0 +1,19 @@ +
+%(error)s + +
+
{L_LOGIN_ACTIVATE_INTRO}
+
+
+ +
+ +
+ +
+
+
+ +
\ No newline at end of file