summaryrefslogtreecommitdiff
path: root/www
diff options
context:
space:
mode:
Diffstat (limited to 'www')
-rw-r--r--www/profile.php41
-rw-r--r--www/register.php34
-rw-r--r--www/scuttle.css4
3 files changed, 67 insertions, 12 deletions
diff --git a/www/profile.php b/www/profile.php
index 35864db..ccdb7a8 100644
--- a/www/profile.php
+++ b/www/profile.php
@@ -103,7 +103,7 @@ if (POST_SUBMITTED!='' && $currentUser->getId() == $userid) {
}
if (!$error) {
if (!$userservice->updateUser($userid, $detPass, $detName, $detMail, $detPage, $detDesc)) {
- $tplvars['error'] = T_('An error occurred while saving your changes.');
+ $tplVars['error'] = T_('An error occurred while saving your changes.');
} else {
$tplVars['msg'] = T_('Changes saved.');
}
@@ -114,14 +114,49 @@ if (POST_SUBMITTED!='' && $currentUser->getId() == $userid) {
if (!$userservice->isLoggedOn() || $currentUser->getId() != $userid) {
$templatename = 'profile.tpl.php';
} else {
+ $scert = SemanticScuttle_Service_Factory::get('User_SslClientCert');
+
+ if (isset($_POST['action']) && $_POST['action'] == 'registerCurrentCert') {
+ if (!$scert->hasValidCert()) {
+ $tplVars['error'] = T_('You do not have a valid SSL client certificate');
+ } else if (false !== $scert->getUserIdFromCert()) {
+ $tplVars['error'] = T_('This certificate is already registered');
+ } else if (false === $scert->registerCurrentCertificate($currentUser->getId())) {
+ $tplVars['error'] = T_('Failed to register SSL client certificate.');
+ } else {
+ $tplVars['msg'] = T_('SSL client certificate registered.');
+ }
+ } else if (isset($_POST['action']) && $_POST['action'] == 'deleteClientCert'
+ && isset($_POST['certId'])
+ ) {
+ $certId = (int)$_POST['certId'];
+ $cert = $scert->getCert($certId);
+
+ if ($cert === null) {
+ $tplVars['error'] = T_('Certificate not found.');
+ } else if ($cert->uId != $currentUser->getId()) {
+ $tplVars['error'] = T_('The certificate does not belong to you.');
+ } else if (false === $scert->delete($certId)) {
+ $tplVars['error'] = T_('Failed to delete SSL client certificate.');
+ } else {
+ $tplVars['msg'] = T_('SSL client certificate deleted.');
+ }
+ }
+
//Token Init
$_SESSION['token'] = md5(uniqid(rand(), true));
$_SESSION['token_stamp'] = time();
$templatename = 'editprofile.tpl.php';
- $tplVars['formaction'] = createURL('profile', $user);
- $tplVars['token'] = $_SESSION['token'];
+ $tplVars['formaction'] = createURL('profile', $user);
+ $tplVars['token'] = $_SESSION['token'];
+
+ $tplVars['sslClientCerts'] = $scert->getUserCerts($currentUser->getId());
+ $tplVars['currentCert'] = null;
+ if ($scert->hasValidCert()) {
+ $tplVars['currentCert'] = SemanticScuttle_Model_User_SslClientCert::fromCurrentCert();
+ }
}
$tplVars['objectUser'] = $userinfo;
diff --git a/www/register.php b/www/register.php
index c01939a..d78ede3 100644
--- a/www/register.php
+++ b/www/register.php
@@ -34,7 +34,13 @@ if (!$GLOBALS['enableRegistration']) {
isset($_POST['submitted']) ? define('POST_SUBMITTED', $_POST['submitted']): define('POST_SUBMITTED', '');
isset($_POST['username']) ? define('POST_USERNAME', $_POST['username']): define('POST_USERNAME', '');
isset($_POST['password']) ? define('POST_PASS', $_POST['password']): define('POST_PASS', '');
-isset($_POST['email']) ? define('POST_MAIL', $_POST['email']): define('POST_MAIL', '');
+if (isset($_POST['email'])) {
+ define('POST_MAIL', $_POST['email']);
+} else if (isset($_SERVER['SSL_CLIENT_S_DN_Email'])) {
+ define('POST_MAIL', $_SERVER['SSL_CLIENT_S_DN_Email']);
+} else {
+ define('POST_MAIL', '');
+}
isset($_POST['antispamAnswer']) ? define('POST_ANTISPAMANSWER', $_POST['antispamAnswer']): define('POST_ANTISPAMANSWER', '');
@@ -66,15 +72,25 @@ if (POST_SUBMITTED != '') {
$tplVars['error'] = T_('Antispam answer is not valid. Please try again.');
// Register details
- } elseif ($userservice->addUser($posteduser, POST_PASS, POST_MAIL) !== false) {
- // Log in with new username
- $login = $userservice->login($posteduser, POST_PASS);
- if ($login) {
- header('Location: '. createURL('bookmarks', $posteduser));
- }
- $tplVars['msg'] = T_('You have successfully registered. Enjoy!');
} else {
- $tplVars['error'] = T_('Registration failed. Please try again.');
+ $uId = $userservice->addUser($posteduser, POST_PASS, POST_MAIL);
+ if ($uId !== false) {
+ if (isset($_SERVER['SSL_CLIENT_VERIFY'])
+ && $_SERVER['SSL_CLIENT_VERIFY'] == 'SUCCESS'
+ ) {
+ $ssl = SemanticScuttle_Service_Factory::get('User_SslClientCert');
+ $ssl->registerCurrentCertificate($uId);
+ $ssl->updateProfileFromCurentCert($uId);
+ }
+ // Log in with new username
+ $login = $userservice->login($posteduser, POST_PASS);
+ if ($login) {
+ header('Location: '. createURL('bookmarks', $posteduser));
+ }
+ $tplVars['msg'] = T_('You have successfully registered. Enjoy!');
+ } else {
+ $tplVars['error'] = T_('Registration failed. Please try again.');
+ }
}
}
diff --git a/www/scuttle.css b/www/scuttle.css
index 78f24e9..9e87857 100644
--- a/www/scuttle.css
+++ b/www/scuttle.css
@@ -455,6 +455,10 @@ table.profile th {
width: 10em;
}
+table tr.ssl-current td {
+ background-color: #AFA;
+}
+
/* OTHER GUFF */
dd {