Updated param name
This commit is contained in:
parent
4bf990420b
commit
0e44a35215
|
@ -7,6 +7,7 @@ use Utopia\Validator\Text;
|
|||
use Utopia\Validator\Email;
|
||||
use Auth\Auth;
|
||||
use Auth\Validator\Password;
|
||||
use Database\Database;
|
||||
use Database\Document;
|
||||
use Database\Validator\Authorization;
|
||||
use DeviceDetector\DeviceDetector;
|
||||
|
@ -275,6 +276,19 @@ $utopia->patch('/v1/account/email')
|
|||
throw new Exception('Invalid credentials', 401);
|
||||
}
|
||||
|
||||
$profile = $projectDB->getCollection([ // Get user by email address
|
||||
'limit' => 1,
|
||||
'first' => true,
|
||||
'filters' => [
|
||||
'$collection=' . Database::SYSTEM_COLLECTION_USERS,
|
||||
'email=' . $email
|
||||
]
|
||||
]);
|
||||
|
||||
if(!empty($profile)) {
|
||||
throw new Exception('User already registered', 400);
|
||||
}
|
||||
|
||||
// TODO after this user needs to confirm mail again
|
||||
|
||||
$user = $projectDB->updateDocument(array_merge($user->getArrayCopy(), [
|
||||
|
|
|
@ -410,21 +410,21 @@ $utopia->delete('/v1/auth/logout')
|
|||
}
|
||||
);
|
||||
|
||||
$utopia->delete('/v1/auth/logout/:userId')
|
||||
$utopia->delete('/v1/auth/logout/:id')
|
||||
->desc('Logout Specific Session')
|
||||
->label('scope', 'account')
|
||||
->label('sdk.namespace', 'auth')
|
||||
->label('sdk.method', 'logoutBySession')
|
||||
->label('sdk.description', 'Use this endpoint to log out the currently logged in user from all his account sessions across all his different devices. When using the option id argument, only the session unique ID provider will be deleted.')
|
||||
->label('abuse-limit', 100)
|
||||
->param('userId', null, function () {return new UID();}, 'User specific session unique ID number. if 0 delete all sessions.')
|
||||
->param('id', null, function () {return new UID();}, 'User specific session unique ID number. if 0 delete all sessions.')
|
||||
->action(
|
||||
function($userId) use ($response, $request, $user, $projectDB, $audit)
|
||||
function($id) use ($response, $request, $user, $projectDB, $audit)
|
||||
{
|
||||
$tokens = $user->getAttribute('tokens', []);
|
||||
|
||||
foreach($tokens as $token) { /* @var $token Document */
|
||||
if(($userId == $token->getUid() || ($userId == 0)) && Auth::TOKEN_TYPE_LOGIN == $token->getAttribute('type')) {
|
||||
if(($id == $token->getUid() || ($id == 0)) && Auth::TOKEN_TYPE_LOGIN == $token->getAttribute('type')) {
|
||||
|
||||
if(!$projectDB->deleteDocument($token->getUid())) {
|
||||
throw new Exception('Failed to remove token from DB', 500);
|
||||
|
|
Loading…
Reference in a new issue