Updated email verification
This commit is contained in:
parent
de4a606975
commit
29c5e5e560
11 changed files with 50 additions and 37 deletions
|
@ -268,8 +268,8 @@ $collections = [
|
|||
],
|
||||
[
|
||||
'$collection' => Database::SYSTEM_COLLECTION_RULES,
|
||||
'label' => 'Confirmation Status',
|
||||
'key' => 'confirm',
|
||||
'label' => 'Email Verification Status',
|
||||
'key' => 'emailVerification',
|
||||
'type' => 'boolean',
|
||||
'default' => '',
|
||||
'required' => true,
|
||||
|
|
|
@ -50,9 +50,9 @@ $utopia->post('/v1/account')
|
|||
->label('sdk.method', 'create')
|
||||
->label('sdk.description', '/docs/references/account/create.md')
|
||||
->label('abuse-limit', 10)
|
||||
->param('email', '', function () { return new Email(); }, 'Account email')
|
||||
->param('password', '', function () { return new Password(); }, 'User password')
|
||||
->param('name', '', function () { return new Text(100); }, 'User name', true)
|
||||
->param('email', '', function () { return new Email(); }, 'Account email.')
|
||||
->param('password', '', function () { return new Password(); }, 'User password.')
|
||||
->param('name', '', function () { return new Text(100); }, 'User name.', true)
|
||||
->action(
|
||||
function ($email, $password, $name) use ($register, $request, $response, $audit, $projectDB, $project, $webhook, $oauthKeys) {
|
||||
if ('console' === $project->getUid()) {
|
||||
|
@ -95,11 +95,11 @@ $utopia->post('/v1/account')
|
|||
'write' => ['user:{self}'],
|
||||
],
|
||||
'email' => $email,
|
||||
'emailVerification' => false,
|
||||
'status' => Auth::USER_STATUS_UNACTIVATED,
|
||||
'password' => Auth::passwordHash($password),
|
||||
'password-update' => time(),
|
||||
'registration' => time(),
|
||||
'confirm' => false,
|
||||
'reset' => false,
|
||||
'name' => $name,
|
||||
]);
|
||||
|
@ -147,8 +147,8 @@ $utopia->post('/v1/account/sessions')
|
|||
->label('sdk.description', '/docs/references/account/create-session.md')
|
||||
->label('abuse-limit', 10)
|
||||
->label('abuse-key', 'url:{url},email:{param-email}')
|
||||
->param('email', '', function () { return new Email(); }, 'User account email address')
|
||||
->param('password', '', function () { return new Password(); }, 'User account password')
|
||||
->param('email', '', function () { return new Email(); }, 'User account email address.')
|
||||
->param('password', '', function () { return new Password(); }, 'User account password.')
|
||||
->action(
|
||||
function ($email, $password) use ($response, $request, $projectDB, $audit, $webhook) {
|
||||
$profile = $projectDB->getCollection([ // Get user by email address
|
||||
|
@ -388,11 +388,11 @@ $utopia->get('/v1/account/sessions/oauth/:provider/redirect')
|
|||
'$collection' => Database::SYSTEM_COLLECTION_USERS,
|
||||
'$permissions' => ['read' => ['*'], 'write' => ['user:{self}']],
|
||||
'email' => $email,
|
||||
'emailVerification' => true,
|
||||
'status' => Auth::USER_STATUS_ACTIVATED, // Email should already be authenticated by OAuth provider
|
||||
'password' => Auth::passwordHash(Auth::passwordGenerator()),
|
||||
'password-update' => time(),
|
||||
'registration' => time(),
|
||||
'confirm' => true,
|
||||
'reset' => false,
|
||||
'name' => $name,
|
||||
]);
|
||||
|
@ -737,6 +737,7 @@ $utopia->patch('/v1/account/email')
|
|||
|
||||
$user = $projectDB->updateDocument(array_merge($user->getArrayCopy(), [
|
||||
'email' => $email,
|
||||
'emailVerification' => false,
|
||||
]));
|
||||
|
||||
if (false === $user) {
|
||||
|
@ -1103,7 +1104,7 @@ $utopia->put('/v1/account/recovery')
|
|||
$profile = $projectDB->updateDocument(array_merge($profile->getArrayCopy(), [
|
||||
'password' => Auth::passwordHash($passwordA),
|
||||
'password-update' => time(),
|
||||
'confirm' => true,
|
||||
'emailVerification' => true,
|
||||
]));
|
||||
|
||||
if (false === $profile) {
|
||||
|
@ -1130,8 +1131,8 @@ $utopia->put('/v1/account/recovery')
|
|||
}
|
||||
);
|
||||
|
||||
$utopia->post('/v1/account/verification')
|
||||
->desc('Create Verification')
|
||||
$utopia->post('/v1/account/verification/email')
|
||||
->desc('Create Email Verification')
|
||||
->label('scope', 'account')
|
||||
->label('sdk.platform', [APP_PLATFORM_CLIENT])
|
||||
->label('sdk.namespace', 'account')
|
||||
|
@ -1139,7 +1140,7 @@ $utopia->put('/v1/account/recovery')
|
|||
->label('sdk.description', '/docs/references/account/create-verification.md')
|
||||
->label('abuse-limit', 10)
|
||||
->label('abuse-key', 'url:{url},email:{param-email}')
|
||||
->param('url', '', function () use ($clients) { return new Host($clients); }, 'URL to redirect the user back to your app from the verification email.') // TODO add our own built-in confirm page
|
||||
->param('url', '', function () use ($clients) { return new Host($clients); }, 'URL to redirect the user back to your app from the verification email.') // TODO add built-in confirm page
|
||||
->action(
|
||||
function ($url) use ($request, $response, $register, $user, $project, $projectDB, $audit) {
|
||||
$verificationSecret = Auth::tokenGenerator();
|
||||
|
@ -1210,7 +1211,7 @@ $utopia->put('/v1/account/recovery')
|
|||
);
|
||||
|
||||
$utopia->put('/v1/account/verification')
|
||||
->desc('Updated Verification')
|
||||
->desc('Complete Email Verification')
|
||||
->label('scope', 'public')
|
||||
->label('sdk.platform', [APP_PLATFORM_CLIENT])
|
||||
->label('sdk.namespace', 'account')
|
||||
|
@ -1244,7 +1245,7 @@ $utopia->put('/v1/account/verification')
|
|||
Authorization::setRole('user:'.$profile->getUid());
|
||||
|
||||
$profile = $projectDB->updateDocument(array_merge($profile->getArrayCopy(), [
|
||||
'confirm' => true,
|
||||
'emailVerification' => true,
|
||||
]));
|
||||
|
||||
if (false === $profile) {
|
||||
|
|
|
@ -376,7 +376,7 @@ $utopia->get('/v1/database/collections/:collectionId/documents')
|
|||
->label('sdk.method', 'listDocuments')
|
||||
->label('sdk.description', '/docs/references/database/list-documents.md')
|
||||
->param('collectionId', null, function () { return new UID(); }, 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/database?platform=server#createCollection).')
|
||||
->param('filters', [], function () { return new ArrayList(new Text(128)); }, 'Array of filter strings. Each filter is constructed from a key name, comparison operator (=, !=, >, <, <=, >=) and a value. You can also use a dot (.) separator in attribute names to filter by child document attributes. Examples: \'name=John Doe\' or \'category.$uid>=5bed2d152c362\'', true)
|
||||
->param('filters', [], function () { return new ArrayList(new Text(128)); }, 'Array of filter strings. Each filter is constructed from a key name, comparison operator (=, !=, >, <, <=, >=) and a value. You can also use a dot (.) separator in attribute names to filter by child document attributes. Examples: \'name=John Doe\' or \'category.$uid>=5bed2d152c362\'.', true)
|
||||
->param('offset', 0, function () { return new Range(0, 900000000); }, 'Offset value. Use this value to manage pagination.', true)
|
||||
->param('limit', 50, function () { return new Range(0, 1000); }, 'Maximum number of documents to return in response. Use this value to manage pagination.', true)
|
||||
->param('order-field', '$uid', function () { return new Text(128); }, 'Document field that results will be sorted by.', true)
|
||||
|
@ -443,7 +443,7 @@ $utopia->get('/v1/database/collections/:collectionId/documents/:documentId')
|
|||
->label('sdk.method', 'getDocument')
|
||||
->label('sdk.description', '/docs/references/database/get-document.md')
|
||||
->param('collectionId', null, function () { return new UID(); }, 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/database?platform=server#createCollection).')
|
||||
->param('documentId', null, function () { return new UID(); }, 'Document unique ID')
|
||||
->param('documentId', null, function () { return new UID(); }, 'Document unique ID.')
|
||||
->action(
|
||||
function ($collectionId, $documentId) use ($response, $request, $projectDB, $isDev) {
|
||||
$document = $projectDB->getDocument($documentId, $isDev);
|
||||
|
@ -489,8 +489,8 @@ $utopia->patch('/v1/database/collections/:collectionId/documents/:documentId')
|
|||
->label('sdk.method', 'updateDocument')
|
||||
->label('sdk.description', '/docs/references/database/update-document.md')
|
||||
->param('collectionId', null, function () { return new UID(); }, 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/database?platform=server#createCollection).')
|
||||
->param('documentId', null, function () { return new UID(); }, 'Document unique ID')
|
||||
->param('data', [], function () { return new \Utopia\Validator\Mock(); }, 'Document data as JSON string')
|
||||
->param('documentId', null, function () { return new UID(); }, 'Document unique ID.')
|
||||
->param('data', [], function () { return new \Utopia\Validator\Mock(); }, 'Document data as JSON string.')
|
||||
->param('read', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.')
|
||||
->param('write', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.')
|
||||
->action(
|
||||
|
@ -568,7 +568,7 @@ $utopia->delete('/v1/database/collections/:collectionId/documents/:documentId')
|
|||
->label('sdk.method', 'deleteDocument')
|
||||
->label('sdk.description', '/docs/references/database/delete-document.md')
|
||||
->param('collectionId', null, function () { return new UID(); }, 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/database?platform=server#createCollection).')
|
||||
->param('documentId', null, function () { return new UID(); }, 'Document unique ID')
|
||||
->param('documentId', null, function () { return new UID(); }, 'Document unique ID.')
|
||||
->action(
|
||||
function ($collectionId, $documentId) use ($response, $projectDB, $audit, $webhook, $isDev) {
|
||||
$collection = $projectDB->getDocument($collectionId, $isDev);
|
||||
|
|
|
@ -125,7 +125,7 @@ $utopia->post('/v1/storage/files')
|
|||
->label('sdk.method', 'createFile')
|
||||
->label('sdk.description', '/docs/references/storage/create-file.md')
|
||||
->label('sdk.consumes', 'multipart/form-data')
|
||||
->param('file', [], function () { return new File(); }, 'Binary Files.', false)
|
||||
->param('file', [], function () { return new File(); }, 'Binary File.', false)
|
||||
->param('read', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.')
|
||||
->param('write', [], function () { return new ArrayList(new Text(64)); }, 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.')
|
||||
// ->param('folderId', '', function () { return new UID(); }, 'Folder to associate files with.', true)
|
||||
|
|
|
@ -250,11 +250,11 @@ $utopia->post('/v1/teams/:teamId/memberships')
|
|||
'write' => ['user:{self}'],
|
||||
],
|
||||
'email' => $email,
|
||||
'emailVerification' => false,
|
||||
'status' => Auth::USER_STATUS_UNACTIVATED,
|
||||
'password' => Auth::passwordHash(Auth::passwordGenerator()),
|
||||
'password-update' => time(),
|
||||
'registration' => time(),
|
||||
'confirm' => false,
|
||||
'reset' => false,
|
||||
'name' => $name,
|
||||
'tokens' => [],
|
||||
|
@ -475,7 +475,7 @@ $utopia->patch('/v1/teams/:teamId/memberships/:inviteId/status')
|
|||
;
|
||||
|
||||
$user
|
||||
->setAttribute('confirm', true)
|
||||
->setAttribute('emailVerification', true)
|
||||
->setAttribute('memberships', $membership, Document::SET_TYPE_APPEND)
|
||||
;
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ $utopia->post('/v1/users')
|
|||
'password' => Auth::passwordHash($password),
|
||||
'password-update' => time(),
|
||||
'registration' => time(),
|
||||
'confirm' => false,
|
||||
'emailVerification' => false,
|
||||
'reset' => false,
|
||||
'name' => $name,
|
||||
]);
|
||||
|
@ -80,7 +80,7 @@ $utopia->post('/v1/users')
|
|||
'status',
|
||||
'email',
|
||||
'registration',
|
||||
'confirm',
|
||||
'emailVerification',
|
||||
'name',
|
||||
], $oauthKeys)), ['roles' => []]));
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ $utopia->get('/v1/users')
|
|||
'status',
|
||||
'email',
|
||||
'registration',
|
||||
'confirm',
|
||||
'emailVerification',
|
||||
'name',
|
||||
],
|
||||
$oauthKeys
|
||||
|
@ -173,7 +173,7 @@ $utopia->get('/v1/users/:userId')
|
|||
'status',
|
||||
'email',
|
||||
'registration',
|
||||
'confirm',
|
||||
'emailVerification',
|
||||
'name',
|
||||
],
|
||||
$oauthKeys
|
||||
|
@ -379,7 +379,7 @@ $utopia->patch('/v1/users/:userId/status')
|
|||
'status',
|
||||
'email',
|
||||
'registration',
|
||||
'confirm',
|
||||
'emailVerification',
|
||||
'name',
|
||||
], $oauthKeys)), ['roles' => []]));
|
||||
}
|
||||
|
|
|
@ -113,11 +113,11 @@ $providers = $this->getParam('providers', []);
|
|||
<small data-ls-bind="{{user.email}}"></span>
|
||||
</td>
|
||||
<td data-title="Status: ">
|
||||
<span data-ls-if="{{user.confirm}} === true">
|
||||
<span data-ls-if="{{user.emailVerification}} === true">
|
||||
<span class="tag green">Verified</span>
|
||||
</span>
|
||||
|
||||
<span data-ls-if="{{user.confirm}} !== true">
|
||||
<span data-ls-if="{{user.emailVerification}} !== true">
|
||||
<span class="tag">Unverified</span>
|
||||
</span>
|
||||
|
||||
|
|
|
@ -32,10 +32,10 @@
|
|||
|
||||
<div class="margin-top-small" data-ls-bind="Member since {{user.registration|date-text}}"></div>
|
||||
<div class="margin-top-small">
|
||||
<span data-ls-if="{{user.confirm}} === true" style="display: none;">
|
||||
<span data-ls-if="{{user.emailVerification}} === true" style="display: none;">
|
||||
<span class="tag green">Verified</span>
|
||||
</span>
|
||||
<span data-ls-if="{{user.confirm}} !== true" style="display: none;">
|
||||
<span data-ls-if="{{user.emailVerification}} !== true" style="display: none;">
|
||||
<span class="tag">Unverified</span>
|
||||
</span>
|
||||
</div>
|
||||
|
|
2
public/dist/styles/default-ltr.css
vendored
2
public/dist/styles/default-ltr.css
vendored
File diff suppressed because one or more lines are too long
2
public/dist/styles/default-rtl.css
vendored
2
public/dist/styles/default-rtl.css
vendored
File diff suppressed because one or more lines are too long
|
@ -3,9 +3,21 @@ html.home {
|
|||
padding: 0 50px;
|
||||
}
|
||||
|
||||
.logo img {
|
||||
max-height: 35px;
|
||||
margin: 45px 25px 25px 25px;
|
||||
.logo {
|
||||
a {
|
||||
display: block;
|
||||
border-bottom: none;
|
||||
|
||||
&:hover {
|
||||
opacity: .8;
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
img {
|
||||
max-height: 35px;
|
||||
margin: 45px 25px 25px 25px;
|
||||
}
|
||||
}
|
||||
|
||||
footer {
|
||||
|
|
Loading…
Reference in a new issue