Skip to content

Commit

Permalink
Merge pull request #64 from SlateFoundation/development
Browse files Browse the repository at this point in the history
Release: slate v2.1.8
  • Loading branch information
themightychris authored Sep 27, 2016
2 parents f89c663 + b04f109 commit 275197c
Show file tree
Hide file tree
Showing 156 changed files with 1,234 additions and 13,979 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

if ($_EVENT['Person']->TemporaryPassword && $_EVENT['Person']->verifyPassword($_EVENT['Person']->TemporaryPassword)) {
$params = [];

if (!empty($_EVENT['requestData']['return'])) {
$params['return'] = $_EVENT['requestData']['return'];
}

Site::redirect('/register/set-password', $params);
}
46 changes: 24 additions & 22 deletions html-templates/connectors/syncronizeComplete.email.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,33 @@
<h2>Log</h2>
<div class="sync-log">
{foreach item=entry from=$Job->log}
<div class="log-entry">
<div>{$entry.message|escape}</div>
{if $entry.level != 'debug'}
<div class="log-entry">
<div>{$entry.message|escape}</div>

{if $entry.changes}
<dl>
{foreach item=delta key=field from=$entry.changes}
<dt>{$field}</dt>
<dd>{$delta.from|escape} -> {$delta.to|escape}</dd>
{/foreach}
</dl>
{/if}
{if $entry.changes}
<dl>
{foreach item=delta key=field from=$entry.changes}
<dt>{$field}</dt>
<dd>{$delta.from|escape} -> {$delta.to|escape}</dd>
{/foreach}
</dl>
{/if}

{if $entry.validationErrors}
<dl>
{foreach item=error key=field from=$entry.validationErrors}
<dt>{$field}</dt>
<dd>{$error|escape}</dd>
{/foreach}
</dl>
{/if}
{if $entry.validationErrors}
<dl>
{foreach item=error key=field from=$entry.validationErrors}
<dt>{$field}</dt>
<dd>{$error|escape}</dd>
{/foreach}
</dl>
{/if}

{if $entry.exception}
<details><pre>{$entry.exception|print_r:true|escape}</pre></details>
{/if}
</div>
{if $entry.exception}
<details><pre>{$entry.exception|print_r:true|escape}</pre></details>
{/if}
</div>
{/if}
{/foreach}
</div>
</body>
Expand Down
6 changes: 3 additions & 3 deletions html-templates/connectors/syncronizeComplete.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
.sync-log .level-notice { color: orange; }
.sync-log .level-info { color: skyblue; }
.sync-log .level-debug { color: lightgray; display: none; }
.sync-log.show-debug .level-debug {
display: block;
}
Expand Down Expand Up @@ -65,9 +65,9 @@
</dl>
{/if}

{if $entry.exception}
{*if $entry.exception}
<details><pre>{$entry.exception|print_r:true|escape}</pre></details>
{/if}
{/if*}
</article>
{/foreach}
</section>
Expand Down
17 changes: 0 additions & 17 deletions html-templates/includes/site.ext-bootstrap.tpl

This file was deleted.

3 changes: 2 additions & 1 deletion html-templates/includes/site.user-tools.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
<ul class="omnibar-items">
{if $.User}
<li class="omnibar-item">
<a class="omnibar-link root-link" href="/">
<a class="omnibar-link root-link" href="/dashboard">
<img class="slate-logo" src="{versioned_url img/slate-logo-white.svg}" width="41" height="32" alt="Slate">
&ensp;Dashboard
</a>
</li>
{/if}
Expand Down
67 changes: 67 additions & 0 deletions html-templates/register/setPassword.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{extends "designs/site.tpl"}

{block "title"}Set Password &mdash; {$dwoo.parent}{/block}

{block "content"}
<header class="page-header">
<h1 class="header-title title-1">Create Your Password</h1>
</header>

<p class="page-info">Your current password was generated to help you start using {Site::getConfig(primary_hostname)}.</p>

<p>Create your own password to use for logging in going forward.</p>

{if $error}
<div class="notify error">{$error|escape}</div>
{/if}

<form method="POST" class="generic single" id="slate-set-password-form">
<input type="hidden" name="returnUrl" value="{refill field=returnUrl default=$returnUrl}">

<fieldset class="shrink">
{field inputName=password type=password label='New Password' required=true attribs='autofocus'}
{field inputName=passwordConfirm type=password label='Confirm' required=true hint='Type the same password twice to confirm it'}

<div class="submit-area">
<input type="submit" class="button submit" value="Set Password">
<span class="submit-text">or <a href="{$returnUrl|escape|default:'/dashboard'}">skip for now</a></span>
</div>
</fieldset>
</form>

{if RemoteSystems\GoogleApps::$domain}
<script src="https://ssl.gstatic.com/accounts/chrome/users-1.0.js"></script>
<script>
google.principal.initialize(function() {
var passwordForm = document.getElementById('slate-set-password-form'),
token = Math.random(),
addedPassword;
passwordForm.addEventListener('submit', function(ev) {
var password = passwordForm.password.value;
// skip add call if form invalid or entered password has already been sent
if (!password || password != passwordForm.passwordConfirm.value || password == addedPassword) {
return;
}
ev.preventDefault();
addedPassword = password;
google.principal.add({
token: token,
user: {cat($.User->Username, '@', RemoteSystems\GoogleApps::$domain)|json_encode},
passwordBytes: password,
keyType: 'KEY_TYPE_PASSWORD_PLAIN'
}, function() {
google.principal.complete({
token: token
}, function() {
passwordForm.submit();
});
});
})
});
</script>
{/if}
{/block}
19 changes: 19 additions & 0 deletions html-templates/register/setPasswordComplete.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{extends "designs/site.tpl"}

{block "title"}Password saved &mdash; {$dwoo.parent}{/block}

{block "content"}
<header class="page-header">
<h1 class="header-title title-1">New Password Saved</h1>
</header>

<p class="page-info">Your new password has been saved, remember to use it next time you login.</p>

<p>
{if $returnUrl}
<a class="button submit" href="{$returnUrl|escape}">Finish logging in</a>
{else}
<a class="button submit" href="/dashboard">Continue to your dashboard</a>
{/if}
</p>
{/block}
41 changes: 23 additions & 18 deletions php-classes/Emergence/People/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

use DB;
use VersionedRecord;
use Group;
use PhotoMedia;
use Emergence\Comments\Comment;
use Emergence\CRM\Message;

class Person extends VersionedRecord implements \Emergence\People\IPerson
class Person extends VersionedRecord implements IPerson
{
// support subclassing
public static $rootClass = __CLASS__;
Expand All @@ -32,6 +34,9 @@ class Person extends VersionedRecord implements \Emergence\People\IPerson
,'MiddleName' => [
'notnull' => false
]
,'PreferredName' => [
'default' => null
]
,'Gender' => [
'type' => 'enum'
,'values' => ['Male','Female']
Expand Down Expand Up @@ -73,59 +78,59 @@ class Person extends VersionedRecord implements \Emergence\People\IPerson
public static $relationships = [
'GroupMemberships' => [
'type' => 'one-many'
,'class' => 'GroupMember'
,'class' => Groups\GroupMember::class
,'indexField' => 'GroupID'
,'foreign' => 'PersonID'
]
,'Notes' => [
'type' => 'context-children'
,'class' => 'Note'
,'contextClass' => 'Person'
,'class' => Message::class
,'contextClass' => Person::class
,'order' => ['ID' => 'DESC']
]
,'Groups' => [
'type' => 'many-many'
,'class' => 'Group'
,'linkClass' => 'GroupMember'
,'class' => Groups\Group::class
,'linkClass' => Groups\GroupMember::class
,'linkLocal' => 'PersonID'
,'linkForeign' => 'GroupID'
]
,'PrimaryPhoto' => [
'type' => 'one-one'
,'class' => 'PhotoMedia'
,'class' => PhotoMedia::class
,'local' => 'PrimaryPhotoID'
]
,'Photos' => [
'type' => 'context-children'
,'class' => 'PhotoMedia'
,'class' => PhotoMedia::class
,'contextClass' => __CLASS__
]
,'Comments' => [
'type' => 'context-children'
,'class' => 'Comment'
,'class' => Comment::class
,'contextClass' => __CLASS__
,'order' => ['ID' => 'DESC']
]
,'PrimaryEmail' => [
'type' => 'one-one'
,'class' => '\\Emergence\\People\\ContactPoint\\Email'
,'class' => ContactPoint\Email::class
]
,'PrimaryPhone' => [
'type' => 'one-one'
,'class' => '\\Emergence\\People\\ContactPoint\\Phone'
,'class' => ContactPoint\Phone::class
]
,'PrimaryPostal' => [
'type' => 'one-one'
,'class' => '\\Emergence\\People\\ContactPoint\\Postal'
,'class' => ContactPoint\Postal::class
]
,'ContactPoints' => [
'type' => 'one-many'
,'class' => '\\Emergence\\People\\ContactPoint\\AbstractPoint'
,'class' => ContactPoint\AbstractPoint::class
,'foreign' => 'PersonID'
]
,'Relationships' => [
'type' => 'one-many'
,'class' => 'Emergence\\People\\Relationship'
,'class' => Relationship::class
,'foreign' => 'PersonID'
]
];
Expand Down Expand Up @@ -172,7 +177,7 @@ class Person extends VersionedRecord implements \Emergence\People\IPerson
'qualifiers' => ['group']
,'points' => 1
,'join' => [
'className' => 'GroupMember'
'className' => Groups\GroupMember::class
,'aliasName' => 'GroupMember'
,'localField' => 'ID'
,'foreignField' => 'PersonID'
Expand Down Expand Up @@ -386,14 +391,14 @@ public function save($deep = true)

public static function getGroupConditions($handle, $matchedCondition)
{
$group = Group::getByHandle($handle);
$group = Groups\Group::getByHandle($handle);

if (!$group) {
return false;
}

$containedGroups = DB::allRecords('SELECT ID FROM %s WHERE `Left` BETWEEN %u AND %u', [
Group::$tableName
Groups\Group::$tableName
,$group->Left
,$group->Right
]);
Expand Down
40 changes: 40 additions & 0 deletions php-classes/Emergence/People/RegistrationRequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Emergence\People;

use LoginRequestHandler;


class RegistrationRequestHandler extends \RequestHandler
{
// configurables
Expand All @@ -24,6 +27,8 @@ public static function handleRequest()
switch ($action = static::shiftPath()) {
case 'recover':
return static::handleRecoverPasswordRequest();
case 'set-password':
return static::handleSetPasswordRequest();
case '':
case false:
return static::handleRegistrationRequest();
Expand Down Expand Up @@ -153,4 +158,39 @@ public static function handleRecoverPasswordRequest()
'error' => isset($error) ? $error : false
]);
}

public static function handleSetPasswordRequest()
{
$GLOBALS['Session']->requireAuthentication();
$User = $GLOBALS['Session']->Person;

if (!$User->TemporaryPassword || !$User->verifyPassword($User->TemporaryPassword)) {
return static::throwInvalidRequestError('Since your account is no longer using a temporary password, please visit your profile and confirm your current password to change it');
}

$error = null;
$returnUrl = LoginRequestHandler::getReturnUrl();

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (empty($_POST['password']) || (strlen($_POST['password']) < User::$minPasswordLength)) {
$error = 'Your new password must be at least '.User::$minPasswordLength.' characters long.';
} elseif (empty($_POST['passwordConfirm']) || ($_POST['password'] != $_POST['passwordConfirm'])) {
$error = 'Please enter your new password a second time for confirmation.';
} else {
$User->setClearPassword($_POST['password']);
$User->save();

return static::respond('setPasswordComplete', [
'success' => true,
'returnUrl' => $returnUrl
]);
}
}

return static::respond('setPassword', [
'success' => !$error,
'error' => $error,
'returnUrl' => $returnUrl
]);
}
}
Loading

0 comments on commit 275197c

Please sign in to comment.