aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Email_validation.php
blob: c5799560feaac163ef6feed39b38ca1fdc1da55f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php

namespace Zotlabs\Module;

use Zotlabs\Lib\Config;

class Email_validation extends \Zotlabs\Web\Controller {

	function post() {

		$success = false;
		if($_POST['token']) {
			// This will redirect internally on success unless the channel is auto_created
			if(account_approve(trim(basename($_POST['token'])))) {
				$success = true;
				if(Config::Get('system','auto_channel_create')) {
					$next_page = Config::Get('system', 'workflow_channel_next', 'profiles');
				}
				if($next_page) {
					goaway(z_root() . '/' . $next_page);
				}
			}
		}
		if(! $success) {
			notice( t('Token verification failed.') . EOL);
		}
	}


	function get() {

		if(argc() > 1) {
			$email = hex2bin(argv(1));
		}

		$o = replace_macros(get_markup_template('email_validation.tpl'), [
			'$title' => t('Email Verification Required'),
			'$desc' => sprintf( t('A verification token was sent to your email address [%s]. Enter that token here to complete the account verification step. Please allow a few minutes for delivery, and check your spam folder if you do not see the message.'),$email),
			'$resend' => t('Resend Email'),
			'$email' => bin2hex($email),
			'$submit' => t('Submit'),
			'$token' => [ 'token', t('Validation token'),'','' ],
		]);

		return $o;

	}

}