-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
314 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<database xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/database.xsd"> | ||
<name>*dbname*</name> | ||
<create>true</create> | ||
<overwrite>false</overwrite> | ||
<charset>utf8</charset> | ||
<table> | ||
<name>*dbprefix*spreedme_tps</name> | ||
<declaration> | ||
<field> | ||
<name>id</name> | ||
<type>integer</type> | ||
<unsigned>true</unsigned> | ||
<notnull>true</notnull> | ||
<autoincrement>true</autoincrement> | ||
</field> | ||
<field> | ||
<name>tp</name> | ||
<type>text</type> | ||
<notnull>true</notnull> | ||
<length>64</length> | ||
</field> | ||
<field> | ||
<name>userid</name> | ||
<type>text</type> | ||
<notnull>true</notnull> | ||
<length>64</length> | ||
</field> | ||
<field> | ||
<name>expiration</name> | ||
<type>timestamp</type> | ||
<notnull>true</notnull> | ||
</field> | ||
<index> | ||
<name>spreedme_tps_id_index</name> | ||
<primary>true</primary> | ||
<unique>true</unique> | ||
<field> | ||
<name>id</name> | ||
</field> | ||
</index> | ||
<index> | ||
<name>spreedme_tps_tp_index</name> | ||
<unique>true</unique> | ||
<field> | ||
<name>tp</name> | ||
</field> | ||
</index> | ||
</declaration> | ||
</table> | ||
</database> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
/** | ||
* Nextcloud - spreedme | ||
* | ||
* This file is licensed under the Affero General Public License version 3 or | ||
* later. See the COPYING file. | ||
* | ||
* @author Leon <[email protected]> | ||
* @copyright struktur AG 2016 | ||
*/ | ||
|
||
namespace OCA\SpreedME\Controller; | ||
|
||
use OCA\SpreedME\Security\TemporaryPasswordManager; | ||
use OCA\SpreedME\User\User; | ||
use OCP\AppFramework\Controller; | ||
use OCP\AppFramework\Http\DataResponse; | ||
use OCP\IDBConnection; | ||
use OCP\IRequest; | ||
|
||
class TemporaryPasswordController extends Controller { | ||
|
||
private $user; | ||
private $temporaryPasswordManager; | ||
|
||
public function __construct($appName, IRequest $request, IDBConnection $db) { | ||
parent::__construct($appName, $request); | ||
|
||
if (!empty($userId)) { | ||
$this->user = new User($userId); | ||
} else { | ||
$this->user = new User(); | ||
} | ||
|
||
$this->temporaryPasswordManager = new TemporaryPasswordManager($db); | ||
} | ||
|
||
/** | ||
* @NoAdminRequired | ||
*/ | ||
public function generateTemporaryPassword($userid, $expiration) { | ||
$_response = array('success' => false); | ||
if ($this->user->isSpreedMeAdmin() && $userid !== null && $expiration !== null) { | ||
try { | ||
$_response['tp'] = $this->temporaryPasswordManager->generateTemporaryPassword($userid, $expiration); | ||
$_response['success'] = true; | ||
} catch (\Exception $e) { | ||
$_response['error'] = $e->getCode(); | ||
} | ||
} | ||
|
||
return new DataResponse($_response); | ||
} | ||
|
||
/** | ||
* @NoAdminRequired | ||
* @NoCSRFRequired | ||
* @PublicPage | ||
*/ | ||
public function getTokenWithTemporaryPassword($tp) { | ||
$_response = array('success' => false); | ||
if ($tp) { | ||
try { | ||
$token = $this->temporaryPasswordManager->getSignedComboFromTemporaryPassword($tp); | ||
$_response = array_merge($_response, $token); | ||
$_response['success'] = true; | ||
} catch (\Exception $e) { | ||
$_response['error'] = $e->getCode(); | ||
} | ||
} | ||
|
||
return new DataResponse($_response); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.