forked from OpenStackweb/openstack-org
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMemberVerifyPage.php
More file actions
58 lines (45 loc) · 1.49 KB
/
Copy pathMemberVerifyPage.php
File metadata and controls
58 lines (45 loc) · 1.49 KB
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
50
51
52
53
54
55
56
57
58
<?php
class MemberVerifyPage extends Page {
private static $db = array(
);
private static $has_one = array(
);
}
class MemberVerifyPage_Controller extends Page_Controller {
private static $allowed_actions = array('member');
function init() {
parent::init();
}
public function member() {
$EmailAddress = "";
$Member = "";
// Make sure the access is POST, not GET
if(!$this->request->isPOST()) return $this->httpError(403, 'Access Denied.');
if(!defined('APPSEC')) return $this->httpError(403, 'Access Denied.');
// Make sure the APPSEC shared secret matches
if($this->request->postVar('APPSEC') != APPSEC) return $this->httpError(403, 'Access Denied.');
// Pull email address from POST variables
$EmailAddress = $this->request->postVar('email');
// Sanitize the input
$EmailAddress = convert::raw2sql($EmailAddress);
// If an email address was provided, try to find a member with it
if($EmailAddress) {
$Member = Member::get()->filter('Email',$EmailAddress)->first();
}
$response = new SS_HTTPResponse();
// If a member was found return status 200 and 'OK'
if ($Member && $Member->isFoundationMember()) {
$response->setStatusCode(200);
$response->setBody('OK');
$response->output();
} elseif ($EmailAddress) {
$response->setStatusCode(404);
$response->setBody('No Member Found.');
$response->output();
} else {
$response->setStatusCode(500);
$response->setBody('An error has occurred retrieving a member.');
$response->output();
}
}
}