verifyusr.php3 2.88 KB
Newer Older
1
<?php
Leigh Stoller's avatar
Leigh Stoller committed
2
#
3
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# 
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
Leigh Stoller's avatar
Leigh Stoller committed
23
#
24 25 26
include("defs.php3");

#
27
# Only known and logged in users can be verified. 
28
#
29 30 31
$this_user = CheckLoginOrDie(CHECKLOGIN_UNVERIFIED|CHECKLOGIN_NEWUSER|
			     CHECKLOGIN_WEBONLY|CHECKLOGIN_WIKIONLY);
$uid       = $this_user->uid();
32 33 34

#
# Must provide the key!
35 36 37
#
$optargs = OptionalPageArguments("key", PAGEARG_STRING);

38 39 40 41 42
if (!isset($key) || strcmp($key, "") == 0) {
    USERERROR("Missing field; ".
              "Please go back and fill out the \"key\" field!", 1);
}

43 44 45 46 47
#
# Standard Testbed Header
#
PAGEHEADER("Confirm Verification");

48
#
49
# Grab the status and do the modification.
50
#
51 52
$status   = $this_user->status();
$wikionly = $this_user->wikionly();
53 54

#
55
# No multiple verifications.
56 57 58 59 60 61 62
# 
if (! strcmp($status, TBDB_USERSTATUS_ACTIVE) ||
    ! strcmp($status, TBDB_USERSTATUS_UNAPPROVED)) {
    USERERROR("You have already been verified. If you did not perform ".
	      "this verification, please notify Testbed Operations.", 1);
}

63
#
64 65
# The user is logged in, so all we need to do is confirm the key.
#
66
if ($key != $this_user->verify_key()) {
67
    $key = CleanString($key);
68 69
    USERERROR("The given key \"$key\" is incorrect. ".
	      "Please enter the correct key.", 1);
70 71
}

72 73
if ($status == TBDB_USERSTATUS_NEWUSER) {
    STARTBUSY("Verifying $uid");
74

75
    SUEXEC("nobody", "nobody", "webtbacct verify $uid", SUEXEC_ACTION_DIE);
76
    
77 78 79 80 81
    if ($wikionly) {
	#
	# For wikionly accounts, build the account now.
	# Just builds the wiki account of course (nothing else).
	#
82 83 84
	SUEXEC("nobody", "nobody", "webtbacct add $uid", SUEXEC_ACTION_DIE);

	STOPBUSY();
85

86 87
	#
	# The backend sets the actual WikiName
88 89 90
	#
	$this_user->Refresh();
	$wikiname = $this_user->wikiname();
91

92 93
	echo "<br>".
	    "You have been verified. You may now access the Wiki at<br>".
94 95 96
	    "<a href='$WIKIURL/$wikiname'>$WIKIURL/$wikiname</a>\n";
    }
    else {
97
	STOPBUSY();
98

99
	echo "<br>".
100 101 102 103
	     "You have now been verified. However, your application ".
	    "has not yet been approved. You will receive ".
	    "email when that has been done.\n";
    }
104 105
}
else {
106
    TBERROR("Bad user status '$status' for $uid!", 1);
107
}
108 109 110 111 112

#
# Standard Testbed Footer
# 
PAGEFOOTER();
113 114
?>