File tree Expand file tree Collapse file tree 5 files changed +132
-0
lines changed Expand file tree Collapse file tree 5 files changed +132
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace BNETDocs \Controllers \User ;
4
+
5
+ use \BNETDocs \Models \User \Activate as UserActivateModel ;
6
+ use \CarlBennett \MVC \Libraries \Common ;
7
+ use \CarlBennett \MVC \Libraries \Controller ;
8
+ use \CarlBennett \MVC \Libraries \Router ;
9
+ use \CarlBennett \MVC \Libraries \View ;
10
+
11
+ class Activate extends Controller {
12
+
13
+ public function &run ( Router &$ router , View &$ view , array &$ args ) {
14
+
15
+ $ model = new UserActivateModel ();
16
+
17
+ $ data = $ router ->getRequestQueryArray ();
18
+
19
+ $ model ->token = isset ( $ data [ 't ' ] ) ? $ data [ 't ' ] : null ;
20
+ $ model ->error = 'INVALID_TOKEN ' ;
21
+
22
+ $ view ->render ( $ model );
23
+
24
+ $ model ->_responseCode = 200 ;
25
+ $ model ->_responseHeaders [ 'Content-Type ' ] = $ view ->getMimeType ();
26
+ $ model ->_responseTTL = 0 ;
27
+
28
+ return $ model ;
29
+
30
+ }
31
+
32
+ }
Original file line number Diff line number Diff line change @@ -234,6 +234,9 @@ function main() {
234
234
$ router ->addRoute ( // URL: /user/:id
235
235
"#^/user/(\d+)/?# " , "User \\View " , "User \\ViewHtml "
236
236
);
237
+ $ router ->addRoute ( // URL: /user/activate
238
+ "#^/user/activate/?$# " , "User \\Activate " , "User \\ActivateHtml "
239
+ );
237
240
$ router ->addRoute ( // URL: /user/changepassword
238
241
"#^/user/changepassword/?$# " ,
239
242
"User \\ChangePassword " , "User \\ChangePasswordHtml "
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace BNETDocs \Models \User ;
4
+
5
+ use \CarlBennett \MVC \Libraries \Model ;
6
+
7
+ class Activate extends Model {
8
+
9
+ public $ token ;
10
+ public $ error ;
11
+
12
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace BNETDocs \Templates \User ;
4
+
5
+ use \CarlBennett \MVC \Libraries \Common ;
6
+ use \CarlBennett \MVC \Libraries \Pair ;
7
+
8
+ $ title = 'Activate Account ' ;
9
+ $ description = 'This form allows an individual to activate their account with a token. ' ;
10
+ $ this ->opengraph ->attach ( new Pair ( 'url ' , '/user/activate ' ));
11
+
12
+ switch ( $ this ->getContext ()->error ) {
13
+ case 'INVALID_TOKEN ' :
14
+ $ message = 'The token is expired or invalid and therefore cannot be used. ' ;
15
+ break ;
16
+ default :
17
+ $ message = $ this ->getContext ()->error ;
18
+ }
19
+
20
+ $ this ->additional_css [] = '/a/forms.css ' ;
21
+ require ('./header.inc.phtml ' );
22
+ ?>
23
+ <article>
24
+ <?php if ($ this ->getContext ()->error !== false ) { ?>
25
+ <header>Activate Account</header>
26
+ <?php if (!empty ($ message )) { ?>
27
+ <section class="red">
28
+ <p><?php echo $ message ; ?> </p>
29
+ </section>
30
+ <?php } ?>
31
+ <form method="GET" action="?">
32
+ <section>
33
+ <label for="t">Token:</label><br/>
34
+ <input
35
+ type="text"
36
+ name="t"
37
+ id="token"
38
+ value="<?php echo filter_var ($ this ->getContext ()->token , FILTER_SANITIZE_FULL_SPECIAL_CHARS ); ?> "
39
+ tabindex="1"
40
+ required
41
+ autofocus="autofocus"
42
+ />
43
+ </section>
44
+ <section>
45
+ <input
46
+ type="submit"
47
+ value="Activate Account"
48
+ tabindex="2"
49
+ />
50
+ </section>
51
+ </form>
52
+ <?php } else { ?>
53
+ <header class="green">Account Activated</header>
54
+ <section class="green">
55
+ <p>Your account has been activated successfully!</p>
56
+ <p>Use the navigation to the left to move to another page.</p>
57
+ </section>
58
+ <?php } ?>
59
+ </article>
60
+ <?php require ('./footer.inc.phtml ' ); ?>
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace BNETDocs \Views \User ;
4
+
5
+ use \BNETDocs \Models \User \Activate as UserActivateModel ;
6
+
7
+ use \CarlBennett \MVC \Libraries \Exceptions \IncorrectModelException ;
8
+ use \CarlBennett \MVC \Libraries \Model ;
9
+ use \CarlBennett \MVC \Libraries \Template ;
10
+ use \CarlBennett \MVC \Libraries \View ;
11
+
12
+ class ActivateHtml extends View {
13
+
14
+ public function getMimeType () {
15
+ return 'text/html;charset=utf-8 ' ;
16
+ }
17
+
18
+ public function render ( Model &$ model ) {
19
+ if (!$ model instanceof UserActivateModel) {
20
+ throw new IncorrectModelException ();
21
+ }
22
+ (new Template ( $ model , 'User/Activate ' ))->render ();
23
+ }
24
+
25
+ }
You can’t perform that action at this time.
0 commit comments