mirror of
https://github.com/nextcloud/documentation.git
synced 2026-01-03 02:09:45 +07:00
Fix indents and spaces for two factor provider
This commit is contained in:
@@ -116,6 +116,7 @@ Creating, deleting, updating, searching, login and logout:
|
||||
* :doc:`users`
|
||||
|
||||
Writing a two-factor auth provider:
|
||||
|
||||
* :doc:`two-factor-provider`
|
||||
|
||||
Hooks
|
||||
|
||||
@@ -16,6 +16,8 @@ example below shows a minimalistic example of such a provider.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
|
||||
namespace OCA\TwoFactor_Test\Provider;
|
||||
|
||||
use OCP\Authentication\TwoFactorAuth\IProvider;
|
||||
@@ -24,70 +26,70 @@ example below shows a minimalistic example of such a provider.
|
||||
|
||||
class TwoFactorTestProvider implements IProvider {
|
||||
|
||||
/**
|
||||
* Get unique identifier of this 2FA provider
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getId() {
|
||||
return 'test';
|
||||
}
|
||||
/**
|
||||
* Get unique identifier of this 2FA provider
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getId() {
|
||||
return 'test';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the display name for selecting the 2FA provider
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDisplayName() {
|
||||
return 'Test';
|
||||
}
|
||||
/**
|
||||
* Get the display name for selecting the 2FA provider
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDisplayName() {
|
||||
return 'Test';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the description for selecting the 2FA provider
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription() {
|
||||
return 'Use a test provider';
|
||||
}
|
||||
/**
|
||||
* Get the description for selecting the 2FA provider
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription() {
|
||||
return 'Use a test provider';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the template for rending the 2FA provider view
|
||||
*
|
||||
* @param IUser $user
|
||||
* @return Template
|
||||
*/
|
||||
public function getTemplate(IUser $user) {
|
||||
// If necessary, this is also the place where you might want
|
||||
// to send out a code via e-mail or SMS.
|
||||
/**
|
||||
* Get the template for rending the 2FA provider view
|
||||
*
|
||||
* @param IUser $user
|
||||
* @return Template
|
||||
*/
|
||||
public function getTemplate(IUser $user) {
|
||||
// If necessary, this is also the place where you might want
|
||||
// to send out a code via e-mail or SMS.
|
||||
|
||||
// 'challenge' is the name of the template
|
||||
return new Template('twofactor_test', 'challenge');
|
||||
}
|
||||
// 'challenge' is the name of the template
|
||||
return new Template('twofactor_test', 'challenge');
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the given challenge
|
||||
*
|
||||
* @param IUser $user
|
||||
* @param string $challenge
|
||||
*/
|
||||
public function verifyChallenge(IUser $user, $challenge) {
|
||||
if ($challenge === 'passme') {
|
||||
/**
|
||||
* Verify the given challenge
|
||||
*
|
||||
* @param IUser $user
|
||||
* @param string $challenge
|
||||
*/
|
||||
public function verifyChallenge(IUser $user, $challenge) {
|
||||
if ($challenge === 'passme') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decides whether 2FA is enabled for the given user
|
||||
*
|
||||
* @param IUser $user
|
||||
* @return boolean
|
||||
*/
|
||||
public function isTwoFactorAuthEnabledForUser(IUser $user) {
|
||||
// 2FA is enforced for all users
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decides whether 2FA is enabled for the given user
|
||||
*
|
||||
* @param IUser $user
|
||||
* @return boolean
|
||||
*/
|
||||
public function isTwoFactorAuthEnabledForUser(IUser $user) {
|
||||
// 2FA is enforced for all users
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -100,4 +102,4 @@ providers are registered via ``info.xml``.
|
||||
|
||||
<two-factor-providers>
|
||||
<provider>OCA\TwoFactor_Test\Provider\TwoFactorTestProvider</provider>
|
||||
</two-factor-providers>
|
||||
</two-factor-providers>
|
||||
|
||||
Reference in New Issue
Block a user