├── .gitignore ├── extensions ├── GoogleAuthenticator.php │ ├── users.dat │ ├── tmpl │ │ ├── login-error.php │ │ ├── login.php │ │ ├── loggedin.php │ │ ├── show-qr.php │ │ └── ask-for-otp.php │ ├── example.php │ ├── README │ ├── LICENSE │ ├── lib │ │ └── GoogleAuthenticator.php │ └── web │ │ ├── Users.php │ │ └── index.php ├── Hybrid │ ├── index.html │ ├── resources │ │ ├── index.html │ │ ├── openid_policy.html │ │ ├── openid_xrds.xml │ │ ├── openid_realm.html │ │ └── config.php.tpl │ ├── thirdparty │ │ └── index.html │ ├── Providers │ │ ├── OpenID.php │ │ ├── AOL.php │ │ ├── Foursquare.php │ │ └── Live.php │ ├── User.php │ ├── User_Contact.php │ ├── User_Activity.php │ ├── Logger.php │ ├── User_Profile.php │ ├── Error.php │ └── Storage.php ├── diceware │ ├── composer.json │ └── README.md └── mailer │ └── phpmailer │ ├── composer.json │ └── language │ ├── phpmailer.lang-zh.php │ ├── phpmailer.lang-zh_cn.php │ ├── phpmailer.lang-ch.php │ ├── phpmailer.lang-ja.php │ ├── phpmailer.lang-he.php │ ├── phpmailer.lang-no.php │ ├── phpmailer.lang-cz.php │ ├── phpmailer.lang-lt.php │ ├── phpmailer.lang-se.php │ ├── phpmailer.lang-dk.php │ ├── phpmailer.lang-hu.php │ ├── phpmailer.lang-eo.php │ ├── phpmailer.lang-tr.php │ ├── phpmailer.lang-sk.php │ ├── phpmailer.lang-ar.php │ ├── phpmailer.lang-ca.php │ ├── phpmailer.lang-fr.php │ ├── phpmailer.lang-uk.php │ ├── phpmailer.lang-ru.php │ ├── phpmailer.lang-et.php │ ├── phpmailer.lang-pl.php │ ├── phpmailer.lang-ro.php │ ├── phpmailer.lang-fo.php │ ├── phpmailer.lang-fi.php │ ├── phpmailer.lang-es.php │ ├── phpmailer.lang-de.php │ ├── phpmailer.lang-it.php │ ├── phpmailer.lang-br.php │ └── phpmailer.lang-nl.php ├── components ├── assets │ └── zocial │ │ ├── zocial-regular-webfont.eot │ │ ├── zocial-regular-webfont.ttf │ │ └── zocial-regular-webfont.woff ├── UsrAlerts.php ├── IPasswordHistoryIdentity.php ├── IEditableIdentity.php ├── DicewareAction.php ├── IOneTimePasswordIdentity.php ├── CaptchaFormBehavior.php ├── IManagedIdentity.php ├── IHybridauthIdentity.php ├── IPictureIdentity.php ├── IActivatedIdentity.php ├── ExpiredPasswordBehavior.php ├── FormModelBehavior.php └── OneTimePasswordAction.php ├── tests ├── UserIdentity.php ├── fixtures │ ├── tbl_user_used_passwords.php │ ├── init.php │ └── tbl_users.php ├── User.php ├── bootstrap.php ├── UserLoginAttempt.php ├── UserUsedPassword.php ├── UserRemoteIdentity.php ├── phpunit.xml ├── unit │ ├── ModuleTest.php │ ├── PasswordFormTest.php │ ├── RecoveryFormTest.php │ ├── ProfileFormTest.php │ └── LoginFormTest.php └── config.php ├── views ├── layouts │ └── email.php ├── default │ ├── index.php │ ├── _captcha.php │ ├── _newpassword.php │ ├── reset.php │ ├── updateProfile.php │ ├── generateOTPSecret.php │ ├── viewProfile.php │ ├── verifyOTP.php │ ├── recovery.php │ ├── _form.php │ ├── login.php │ └── _login_remote.php ├── emails │ ├── oneTimePassword.php │ ├── it │ │ ├── oneTimePassword.php │ │ ├── recovery.php │ │ └── verify.php │ ├── pl │ │ ├── oneTimePassword.php │ │ ├── recovery.php │ │ └── verify.php │ ├── recovery.php │ └── verify.php ├── hybridauth │ ├── login.php │ └── confirm.php └── manager │ └── _search.php ├── composer.json ├── migrations ├── m130703_104658_users_add_one_time_password.php ├── m130704_104658_create_table_user_used_passwords.php ├── m130706_104658_create_table_user_login_attempts.php ├── m130702_104658_create_table_user_remote_identities.php ├── m130705_104658_create_table_user_profile_pictures.php └── m130701_104658_create_table_users.php ├── messages ├── config.php ├── cs │ └── usr.php ├── es │ ├── auth.php │ └── manager.php └── pl │ ├── auth.php │ └── manager.php ├── LICENSE ├── models ├── ExampleUserUsedPassword.php ├── ExampleUserProfilePicture.php ├── ExampleUserRemoteIdentity.php ├── PasswordForm.php ├── SearchForm.php └── ExampleUserLoginAttempt.php └── controllers └── UsrController.php /.gitignore: -------------------------------------------------------------------------------- 1 | /tests/report 2 | *.swp 3 | -------------------------------------------------------------------------------- /extensions/GoogleAuthenticator.php/users.dat: -------------------------------------------------------------------------------- 1 | {"chregu":{"password":"foobar"}} -------------------------------------------------------------------------------- /components/assets/zocial/zocial-regular-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nineinchnick/yii-usr/HEAD/components/assets/zocial/zocial-regular-webfont.eot -------------------------------------------------------------------------------- /components/assets/zocial/zocial-regular-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nineinchnick/yii-usr/HEAD/components/assets/zocial/zocial-regular-webfont.ttf -------------------------------------------------------------------------------- /extensions/GoogleAuthenticator.php/tmpl/login-error.php: -------------------------------------------------------------------------------- 1 |

2 | Wrong username or password or token. 3 |

4 |

5 | try again 6 |

-------------------------------------------------------------------------------- /components/assets/zocial/zocial-regular-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nineinchnick/yii-usr/HEAD/components/assets/zocial/zocial-regular-webfont.woff -------------------------------------------------------------------------------- /tests/UserIdentity.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /extensions/Hybrid/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /extensions/Hybrid/resources/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /extensions/Hybrid/thirdparty/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /extensions/Hybrid/resources/openid_policy.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | OpenID Policy 4 | 5 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /extensions/GoogleAuthenticator.php/tmpl/login.php: -------------------------------------------------------------------------------- 1 | 2 |

please login

3 |

4 |

5 | username:
6 | password:
7 | 8 |
-------------------------------------------------------------------------------- /tests/fixtures/tbl_user_used_passwords.php: -------------------------------------------------------------------------------- 1 | 1, 6 | 'password' => '$2y$10$6q8D2lv/K73HNcDoEs01.ODNfLq7Wz/EzoAwtOJ4R8bUmCOujW4ky', 7 | 'set_on' => '2011-11-11 12:34', 8 | ), 9 | ); 10 | -------------------------------------------------------------------------------- /tests/User.php: -------------------------------------------------------------------------------- 1 | 3 | Hello getUsername(); ?> 4 |

5 | 8 | 9 |

10 | Show QR Code 11 |

12 | 13 | 16 | 17 |

18 | Logout 19 |

-------------------------------------------------------------------------------- /tests/UserLoginAttempt.php: -------------------------------------------------------------------------------- 1 | breadcrumbs)) { 5 | $this->breadcrumbs = array($this->module->id); 6 | } 7 | ?> 8 |

uniqueId.'/'.$this->action->id; ?>

9 | 10 | widget('usr.components.UsrAlerts', array('cssClassPrefix' => $this->module->alertCssClassPrefix)); ?> 11 | -------------------------------------------------------------------------------- /views/emails/oneTimePassword.php: -------------------------------------------------------------------------------- 1 |

2 | This message contains a one time password. It was requested on the name, $siteUrl); ?> website. 3 | If you did not perform this request, please ignore this email or contact our administrator. 4 |

5 | 6 |

Enter this code on the page that requested it:

7 |

8 | -------------------------------------------------------------------------------- /views/emails/it/oneTimePassword.php: -------------------------------------------------------------------------------- 1 |

2 | Questo messaggio contiene una password a singolo utilizzo.
3 | É stata inviata da name, $siteUrl); ?>. Se non avete eseguito voi la richiesta ignorate questa mail o contattate l'amministratore. 4 |

5 | 6 |

Inserite il seguente codice nella pagina dai cui è stato richiesto:

7 |

8 | -------------------------------------------------------------------------------- /views/emails/pl/oneTimePassword.php: -------------------------------------------------------------------------------- 1 |

2 | Ta wiadomość zawiera jednorazowe hasło. Została wysłana na polecenie użytkownika w serwisie name, $siteUrl); ?>. Jeśli nie jesteś adresatem tej wiadomości, prosimy o jej zignorowanie lub kontakt z naszym administratorem. 3 |

4 | 5 |

Wprowadź poniższy kod na stronie, która o niego poprosiła:

6 |

7 | -------------------------------------------------------------------------------- /extensions/Hybrid/resources/openid_xrds.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | http://specs.openid.net/auth/2.0/return_to 9 | {RETURN_TO_URL} 10 | 11 | 12 | -------------------------------------------------------------------------------- /extensions/GoogleAuthenticator.php/tmpl/show-qr.php: -------------------------------------------------------------------------------- 1 |

Please scan this

2 | 3 |

with the Google Authenticator App

4 | 5 |

6 | getUrl($user->getUsername(),$_SERVER['HTTP_HOST'],$secret); 9 | ?> 10 | 11 | 12 |

-------------------------------------------------------------------------------- /extensions/Hybrid/Providers/OpenID.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | HybridAuth Endpoint 4 | 5 | 6 | 7 | 8 |

HybridAuth

9 | Open Source Social Sign On PHP Library. 10 |
11 | hybridauth.sourceforge.net/ 12 | 13 | 14 | -------------------------------------------------------------------------------- /views/emails/recovery.php: -------------------------------------------------------------------------------- 1 |

2 | This message contains instructions to perform a password recovery. It was requested on the name, $siteUrl); ?> website. 3 | If you did not perform this request, please ignore this email or contact our administrator. 4 |

5 | 6 |

To set a new password, open the following link:

7 |

8 | 9 |

10 |

11 | If the link does not open correctly, try copying it and pasting in the browser's address bar. 12 |

13 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nineinchnick/yii-usr", 3 | "description": "Yii framework module for user authentication, password reset, registration and profile updating.", 4 | "license": "BSD-3-Clause", 5 | "authors": [ 6 | { 7 | "name": "Jan Waś", 8 | "email": "janek.jan@gmail.com", 9 | "homepage": "http://niix.pl/" 10 | } 11 | ], 12 | "require": { 13 | "php": ">=5.3.0" 14 | }, 15 | "require-dev": { 16 | "php": ">=5.3.0", 17 | "phpunit": "dev-master" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /views/emails/verify.php: -------------------------------------------------------------------------------- 1 |

2 | This message contains instructions to verify this email address. It was requested on the name, $siteUrl); ?> website. 3 | If you did not perform this request, please ignore this email or contact our administrator. 4 |

5 | 6 |

To verify this email address, open the following link:

7 |

8 | 9 |

10 |

11 | If the link does not open correctly, try copying it and pasting in the browser's address bar. 12 |

13 | -------------------------------------------------------------------------------- /extensions/Hybrid/Providers/AOL.php: -------------------------------------------------------------------------------- 1 | 2 | Questo messaggio contiene le istruzioni per effettuare un recupero password.
3 | É stata inviata da name, $siteUrl); ?>. Se non avete eseguito voi la richiesta ignorate questa mail o contattate l'amministratore. 4 |

5 | 6 |

Per impostare una nuova password apri il segunete link:

7 |

8 | 9 |

10 |

11 | Se il link non si apre correttamente provate a copiarlo e incollarlo direttamente nel navigatore. 12 |

13 | -------------------------------------------------------------------------------- /extensions/diceware/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nineinchnick/diceware", 3 | "description": "Diceware passphrase generator", 4 | "keywords": ["diceware", "passphrase", "password generator"], 5 | "authors": [ 6 | { 7 | "name": "Joe Martin", 8 | "email": "jmartin@desertflood.com" 9 | }, 10 | { 11 | "name": "Jan Waś", 12 | "email": "janek.jan@gmail.com", 13 | "homepage": "http://niix.pl/" 14 | } 15 | ], 16 | "autoload": { 17 | "psr-0": { "nineinchnick\\diceware\\": "" } 18 | }, 19 | "target-dir": "nineinchnick/diceware" 20 | } 21 | -------------------------------------------------------------------------------- /views/emails/it/verify.php: -------------------------------------------------------------------------------- 1 |

2 | Questo messaggio contiene istruzioni su come verificare questo indirizzo email.
3 | É stata inviata da name, $siteUrl); ?>. Se non avete eseguito voi la richiesta ignorate questa mail o contattate l'amministratore. 4 |

5 | 6 |

Per confermare questo indirizzo email, seguite il seguente link:

7 |

8 | 9 |

10 |

11 | Se il link non si apre correttamente provate a copiarlo e incollarlo direttamente nel navigatore. 12 |

13 | -------------------------------------------------------------------------------- /views/emails/pl/recovery.php: -------------------------------------------------------------------------------- 1 |

2 | Ta wiadomość zawiera instrukcje, jak wykonać odzyskiwanie hasła. Została wysłana na polecenie użytkownika w serwisie name, $siteUrl); ?>. Jeśli nie jesteś adresatem tej wiadomości, prosimy o jej zignorowanie lub kontakt z naszym administratorem. 3 |

4 | 5 |

Aby ustawić nowe hasło, otwórz poniższy link:

6 |

7 | 8 |

9 |

10 | Jeśli link nie otwiera się poprawnie, spróbuj skopiować go i wkleić w pasek adresu swojej przeglądarki. 11 |

12 | -------------------------------------------------------------------------------- /views/emails/pl/verify.php: -------------------------------------------------------------------------------- 1 |

2 | Ta wiadomość zawiera instrukcje, jak zweryfikować ten adres email. Została wysłana na polecenie użytkownika w serwisie name, $siteUrl); ?>. Jeśli nie jesteś adresatem tej wiadomości, prosimy o jej zignorowanie lub kontakt z naszym administratorem. 3 |

4 | 5 |

Aby zweryfikować ten adres email, otwórz poniższy link:

6 |

7 | 8 |

9 |

10 | Jeśli link nie otwiera się poprawnie, spróbuj skopiować go i wkleić w pasek adresu swojej przeglądarki. 11 |

12 | -------------------------------------------------------------------------------- /views/default/_captcha.php: -------------------------------------------------------------------------------- 1 |
2 | labelEx($model, 'verifyCode'); ?> 3 |
4 | widget('CCaptcha', $this->module->captcha === true ? array() : $this->module->captcha); ?>
5 | textField($model, 'verifyCode'); ?> 6 |
7 |
8 |
9 | 10 |
11 | error($model, 'verifyCode'); ?> 12 |
13 | -------------------------------------------------------------------------------- /extensions/GoogleAuthenticator.php/tmpl/ask-for-otp.php: -------------------------------------------------------------------------------- 1 | 2 |

please otp

3 |

4 |

5 | 6 |
7 | (Set $debug in index.php to false, if you don't want to have the OTP prefilled (for real life application, for example ;))
8 | 9 | 10 | otp:
17 |
18 | 19 | 20 |
-------------------------------------------------------------------------------- /extensions/GoogleAuthenticator.php/example.php: -------------------------------------------------------------------------------- 1 | getCode($secret); 12 | 13 | print "\n"; 14 | 15 | print "Check if $code is valid: "; 16 | 17 | if ($g->checkCode($secret,$code)) { 18 | print "YES \n"; 19 | } else { 20 | print "NO \n"; 21 | } 22 | 23 | $secret = $g->generateSecret(); 24 | print "Get a new Secret: $secret \n"; 25 | 26 | print "The QR Code for this secret (to scan with the Google Authenticator App: \n"; 27 | print $g->getURL('chregu','example.org',$secret); 28 | print "\n"; -------------------------------------------------------------------------------- /migrations/m130703_104658_users_add_one_time_password.php: -------------------------------------------------------------------------------- 1 | addColumn('{{users}}', 'one_time_password_secret', 'string'); 8 | $this->addColumn('{{users}}', 'one_time_password_code', 'string'); 9 | $this->addColumn('{{users}}', 'one_time_password_counter', 'integer NOT NULL DEFAULT 0'); 10 | } 11 | 12 | public function safeDown() 13 | { 14 | $this->dropColumn('{{users}}', 'one_time_password_counter'); 15 | $this->dropColumn('{{users}}', 'one_time_password_code'); 16 | $this->dropColumn('{{users}}', 'one_time_password_secret'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /messages/config.php: -------------------------------------------------------------------------------- 1 | dirname(__FILE__).DIRECTORY_SEPARATOR.'..', 8 | 'messagePath' => dirname(__FILE__), 9 | 'languages' => array('cs', 'de', 'it', 'pl', 'ru'), 10 | 'fileTypes' => array('php'), 11 | 'overwrite' => true, 12 | 'exclude' => array( 13 | '.svn', 14 | '.git', 15 | '.gitignore', 16 | 'yiilite.php', 17 | 'yiit.php', 18 | 'yiic.php', 19 | '/models/Example', 20 | '/messages', 21 | '/tests', 22 | '/migrations', 23 | '/extensions', 24 | ), 25 | ); 26 | -------------------------------------------------------------------------------- /migrations/m130704_104658_create_table_user_used_passwords.php: -------------------------------------------------------------------------------- 1 | createTable('{{user_used_passwords}}', array( 8 | 'id' => 'pk', 9 | 'user_id' => 'integer NOT NULL REFERENCES {{users}} (id) ON UPDATE CASCADE ON DELETE CASCADE', 10 | 'password' => 'string NOT NULL', 11 | 'set_on' => 'timestamp NOT NULL', 12 | )); 13 | $this->createIndex('{{user_used_passwords}}_user_id_idx', '{{user_used_passwords}}', 'user_id'); 14 | } 15 | 16 | public function safeDown() 17 | { 18 | $this->dropTable('{{user_used_passwords}}'); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /components/UsrAlerts.php: -------------------------------------------------------------------------------- 1 | widget('usr.components.UsrAlerts'); 9 | * ~~~ 10 | * 11 | * @author Jan Waś 12 | */ 13 | class UsrAlerts extends CWidget 14 | { 15 | public $cssClassPrefix; 16 | /** 17 | * Renders the widget. 18 | */ 19 | public function run() 20 | { 21 | if (($flashMessages = Yii::app()->user->getFlashes())) { 22 | echo ''; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /components/IPasswordHistoryIdentity.php: -------------------------------------------------------------------------------- 1 | timestamp = time(); 28 | 29 | $this->profile = new Hybrid_User_Profile(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /extensions/GoogleAuthenticator.php/README: -------------------------------------------------------------------------------- 1 | Ported from http://code.google.com/p/google-authenticator/ 2 | 3 | You can use the Google Authenticator app from here 4 | http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=1066447 5 | to generate One Time Passwords/Tokens and check them with this little 6 | PHP app (Of course, you can also create them with this). 7 | 8 | There are many real world applications for that, but noone implemented it yet. 9 | 10 | See example.php for how to use it. 11 | 12 | There's a little web app showing how it works in web/, please make users.dat 13 | writeable for the webserver, doesn't really work otherwise (it can't save the 14 | secret). Try to login with chregu/foobar. 15 | 16 | 17 | What's missing in the example: 18 | *** 19 | 20 | * Prevent replay attacks. One token should only be used once 21 | * Show QR Code only when providing password again (or not at all) 22 | * Regenrate secret -------------------------------------------------------------------------------- /tests/fixtures/init.php: -------------------------------------------------------------------------------- 1 | setDbConnection($this->getDbConnection()); 23 | if ($migration->up() === false) { 24 | echo 'something went terribly wrong!'; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /migrations/m130706_104658_create_table_user_login_attempts.php: -------------------------------------------------------------------------------- 1 | createTable('{{user_login_attempts}}', array( 8 | 'id' => 'pk', 9 | 'username' => 'string NOT NULL', 10 | 'user_id' => 'integer REFERENCES {{users}} (id) ON UPDATE CASCADE ON DELETE CASCADE', 11 | 'performed_on' => 'timestamp NOT NULL', 12 | 'is_successful' => 'boolean NOT NULL DEFAULT false', 13 | 'session_id' => 'string', 14 | 'ipv4' => 'integer', 15 | 'user_agent' => 'string', 16 | )); 17 | 18 | $this->createIndex('{{user_login_attempts}}_user_id_idx', '{{user_login_attempts}}', 'user_id'); 19 | } 20 | 21 | public function safeDown() 22 | { 23 | $this->dropTable('{{user_login_attempts}}'); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /tests/phpunit.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | ../../../yiisoft 11 | ../migrations 12 | ../extensions 13 | ../models/ExampleUser.php 14 | ../models/ExampleUserRemoteIdentity.php 15 | ../models/ExampleUserUsedPassword.php 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /components/IEditableIdentity.php: -------------------------------------------------------------------------------- 1 | assertEquals($module->getVersion(), $composer->version); 12 | }*/ 13 | 14 | public function testCreateForm() 15 | { 16 | $module = new UsrModule('usr', Yii::app()); 17 | $module->loginFormBehaviors = array( 18 | 'expiredPasswordBehavior' => array( 19 | 'class' => 'ExpiredPasswordBehavior', 20 | 'passwordTimeout' => 300, 21 | ), 22 | ); 23 | $form = $module->createFormModel('LoginForm'); 24 | $this->assertTrue($form->asa('expiredPasswordBehavior') instanceof ExpiredPasswordBehavior); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /messages/cs/usr.php: -------------------------------------------------------------------------------- 1 | 'Změna hesla', 21 | 'Current password' => 'Aktuální heslo', 22 | 'New password' => 'Nové heslo', 23 | 'Verify' => 'Ověřit', 24 | 'Username' => 'Uživatelské jméno', 25 | 'Password' => 'Heslo', 26 | ); 27 | -------------------------------------------------------------------------------- /extensions/mailer/phpmailer/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "phpmailer/phpmailer", 3 | "type": "library", 4 | "description": "PHPMailer is a full-featured email creation and transfer class for PHP", 5 | "authors": [ 6 | { 7 | "name": "Jim Jagielski", 8 | "email": "jimjag@gmail.com" 9 | }, 10 | { 11 | "name": "Marcus Bointon", 12 | "email": "phpmailer@synchromedia.co.uk" 13 | }, 14 | { 15 | "name": "Andy Prevost", 16 | "email": "codeworxtech@users.sourceforge.net" 17 | }, 18 | { 19 | "name": "Brent R. Matzelle" 20 | } 21 | ], 22 | "require": { 23 | "php": ">=5.0.0" 24 | }, 25 | "require-dev": { 26 | "phpdocumentor/phpdocumentor": "*", 27 | "phpunit/phpunit": "*" 28 | }, 29 | "autoload": { 30 | "classmap": ["class.phpmailer.php", "class.pop3.php", "class.smtp.php"] 31 | }, 32 | "license": "LGPL-2.1" 33 | } -------------------------------------------------------------------------------- /migrations/m130702_104658_create_table_user_remote_identities.php: -------------------------------------------------------------------------------- 1 | createTable('{{user_remote_identities}}', array( 8 | 'id' => 'pk', 9 | 'user_id' => 'integer NOT NULL REFERENCES {{users}} (id) ON UPDATE CASCADE ON DELETE CASCADE', 10 | 'provider' => 'varchar(100) NOT NULL', 11 | 'identifier' => 'varchar(100) NOT NULL', 12 | 'created_on' => 'timestamp NOT NULL', 13 | 'last_used_on' => 'timestamp', 14 | )); 15 | $this->createIndex('{{user_remote_identities}}_provider_identifier_idx', '{{user_remote_identities}}', 'provider, identifier', true); 16 | $this->createIndex('{{user_remote_identities}}_user_id_idx', '{{user_remote_identities}}', 'user_id'); 17 | } 18 | 19 | public function safeDown() 20 | { 21 | $this->dropTable('{{user_remote_identities}}'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /components/DicewareAction.php: -------------------------------------------------------------------------------- 1 | language); 25 | $password = $diceware->get_phrase($this->length, $this->extraDigit, $this->extraChar); 26 | echo json_encode($password); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tests/fixtures/tbl_users.php: -------------------------------------------------------------------------------- 1 | 'neo', 6 | 'password' => '$2y$10$6q8D2lv/K73HNcDoEs01.ODNfLq7Wz/EzoAwtOJ4R8bUmCOujW4ky', 7 | 'password_set_on' => '2011-11-11 12:34', 8 | 'email' => 'neo@matrix.com', 9 | 'is_active' => 1, 10 | 'is_disabled' => 0, 11 | ), 12 | array( 13 | 'username' => 'tank', 14 | 'password' => '$2y$10$6q8D2lv/K73HNcDoEs01.ODNfLq7Wz/EzoAwtOJ4R8bUmCOujW4ky', 15 | 'password_set_on' => '2012-12-12 10:00', 16 | 'email' => 'tank@matrix.com', 17 | 'is_active' => 0, 18 | 'is_disabled' => 1, 19 | ), 20 | array( 21 | 'username' => 'smith', 22 | 'password' => 'xx', 23 | 'email' => 'smith@matrix.com', 24 | 'is_active' => 0, 25 | 'is_disabled' => 1, 26 | ), 27 | array( 28 | 'username' => 'cat', 29 | 'password' => 'xx', 30 | 'email' => 'cat@matrix.com', 31 | 'is_active' => 1, 32 | 'is_disabled' => 0, 33 | ), 34 | ); 35 | -------------------------------------------------------------------------------- /components/IOneTimePasswordIdentity.php: -------------------------------------------------------------------------------- 1 | user = new stdClass(); 32 | 33 | // typically, we should have a few information about the user who created the event from social apis 34 | $this->user->identifier = NULL; 35 | $this->user->displayName = NULL; 36 | $this->user->profileURL = NULL; 37 | $this->user->photoURL = NULL; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /components/CaptchaFormBehavior.php: -------------------------------------------------------------------------------- 1 | 6 | */ 7 | 8 | /** 9 | * CaptchaFormBehavior adds captcha validation to a form model component. 10 | * The model should extend from {@link CFormModel} or its child classes. 11 | * 12 | * @property CFormModel $owner The owner model that this behavior is attached to. 13 | * 14 | * @author Jan Was 15 | */ 16 | class CaptchaFormBehavior extends FormModelBehavior 17 | { 18 | public $verifyCode; 19 | 20 | /** 21 | * @inheritdoc 22 | */ 23 | public function filterRules($rules = array()) 24 | { 25 | $module = Yii::app()->controller !== null ? Yii::app()->controller->module : null; 26 | $behaviorRules = array( 27 | array('verifyCode', 'captcha', 'captchaAction' => ($module !== null ? $module->getId() : 'usr').'/default/captcha'), 28 | ); 29 | 30 | return array_merge($rules, $this->applyRuleOptions($behaviorRules)); 31 | } 32 | 33 | /** 34 | * @inheritdoc 35 | */ 36 | public function attributeLabels() 37 | { 38 | return array( 39 | 'verifyCode' => Yii::t('UsrModule.usr', 'Verification code'), 40 | ); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /extensions/mailer/phpmailer/language/phpmailer.lang-zh.php: -------------------------------------------------------------------------------- 1 | 6 | */ 7 | 8 | $PHPMAILER_LANG['authenticate'] = 'SMTP 錯誤:登錄失敗。'; 9 | $PHPMAILER_LANG['connect_host'] = 'SMTP 錯誤:無法連接到 SMTP 主機。'; 10 | $PHPMAILER_LANG['data_not_accepted'] = 'SMTP 錯誤:數據不被接受。'; 11 | //$PHPMAILER_LANG['empty_message'] = 'Message body empty'; 12 | $PHPMAILER_LANG['encoding'] = '未知編碼: '; 13 | $PHPMAILER_LANG['file_access'] = '無法訪問文件:'; 14 | $PHPMAILER_LANG['file_open'] = '文件錯誤:無法打開文件:'; 15 | $PHPMAILER_LANG['from_failed'] = '發送地址錯誤:'; 16 | $PHPMAILER_LANG['execute'] = '無法執行:'; 17 | $PHPMAILER_LANG['instantiate'] = '未知函數調用。'; 18 | //$PHPMAILER_LANG['invalid_address'] = 'Not sending, email address is invalid: '; 19 | $PHPMAILER_LANG['provide_address'] = '必須提供至少一個收件人地址。'; 20 | $PHPMAILER_LANG['mailer_not_supported'] = '發信客戶端不被支持。'; 21 | $PHPMAILER_LANG['recipients_failed'] = 'SMTP 錯誤:收件人地址錯誤:'; 22 | //$PHPMAILER_LANG['signing'] = 'Signing Error: '; 23 | //$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.'; 24 | //$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: '; 25 | //$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: '; 26 | -------------------------------------------------------------------------------- /extensions/mailer/phpmailer/language/phpmailer.lang-zh_cn.php: -------------------------------------------------------------------------------- 1 | 6 | */ 7 | 8 | $PHPMAILER_LANG['authenticate'] = 'SMTP 错误:登录失败。'; 9 | $PHPMAILER_LANG['connect_host'] = 'SMTP 错误:无法连接到 SMTP 主机。'; 10 | $PHPMAILER_LANG['data_not_accepted'] = 'SMTP 错误:数据不被接受。'; 11 | //$P$PHPMAILER_LANG['empty_message'] = 'Message body empty'; 12 | $PHPMAILER_LANG['encoding'] = '未知编码: '; 13 | $PHPMAILER_LANG['execute'] = '无法执行:'; 14 | $PHPMAILER_LANG['file_access'] = '无法访问文件:'; 15 | $PHPMAILER_LANG['file_open'] = '文件错误:无法打开文件:'; 16 | $PHPMAILER_LANG['from_failed'] = '发送地址错误:'; 17 | $PHPMAILER_LANG['instantiate'] = '未知函数调用。'; 18 | //$PHPMAILER_LANG['invalid_address'] = 'Not sending, email address is invalid: '; 19 | $PHPMAILER_LANG['mailer_not_supported'] = '发信客户端不被支持。'; 20 | $PHPMAILER_LANG['provide_address'] = '必须提供至少一个收件人地址。'; 21 | $PHPMAILER_LANG['recipients_failed'] = 'SMTP 错误:收件人地址错误:'; 22 | //$PHPMAILER_LANG['signing'] = 'Signing Error: '; 23 | //$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.'; 24 | //$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: '; 25 | //$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: '; 26 | -------------------------------------------------------------------------------- /extensions/mailer/phpmailer/language/phpmailer.lang-ch.php: -------------------------------------------------------------------------------- 1 | createTable('{{user_profile_pictures}}', array( 8 | 'id' => 'pk', 9 | 'user_id' => 'integer NOT NULL REFERENCES {{users}} (id) ON UPDATE CASCADE ON DELETE CASCADE', 10 | 'original_picture_id' => 'integer REFERENCES {{user_profile_pictures}} (id) ON UPDATE CASCADE ON DELETE CASCADE', 11 | 'filename' => 'string NOT NULL', 12 | 'width' => 'integer NOT NULL', 13 | 'height' => 'integer NOT NULL', 14 | 'mimetype' => 'string NOT NULL', 15 | 'created_on' => 'timestamp NOT NULL', 16 | 'contents' => 'text NOT NULL', 17 | )); 18 | $this->createIndex('{{user_profile_pictures}}_user_id_idx', '{{user_profile_pictures}}', 'user_id'); 19 | $this->createIndex('{{user_profile_pictures}}_original_picture_id_idx', '{{user_profile_pictures}}', 'original_picture_id'); 20 | $this->createIndex('{{user_profile_pictures}}_width_height_idx', '{{user_profile_pictures}}', 'width, height'); 21 | } 22 | 23 | public function safeDown() 24 | { 25 | $this->dropTable('{{user_profile_pictures}}'); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /components/IManagedIdentity.php: -------------------------------------------------------------------------------- 1 | 'Crear usuarios', 21 | 'Delete any user' => 'Eliminar cualquier usuario', 22 | 'Manage users' => 'Gestionar usuarios', 23 | 'Read any user' => 'Leer cualquier usuario', 24 | 'Update any user' => 'Actualizar cualquier usuario', 25 | 'Update any user\'s attributes' => 'Actualizar atributos de cualquier usuario', 26 | 'Update any user\'s auth item assignments' => 'Actualizar asignaciones de elementos de autenticación de cualquier usuario', 27 | 'Update any user\'s password' => 'Actualizar la contraseña de cualquier usuario ', 28 | 'Update any user\'s status' => 'Actualizar el estado de cualquier usuario', 29 | ); 30 | -------------------------------------------------------------------------------- /messages/pl/auth.php: -------------------------------------------------------------------------------- 1 | 'Tworzy użytkowników', 21 | 'Delete any user' => 'Usuwa dowolnego użytkownika', 22 | 'Manage users' => 'Zarządza użytkownikami', 23 | 'Read any user' => 'Odczytuje dowolnego użytkownika', 24 | 'Update any user' => 'Aktualizuje dowolnego użytkownika', 25 | 'Update any user\'s attributes' => 'Aktualizuje dane dowolnego użytkownika', 26 | 'Update any user\'s auth item assignments' => 'Aktualizuje przypisanie elementów uprawnień dowolnego użytkownika', 27 | 'Update any user\'s password' => 'Aktualizuje hasło dowolnego użytkownika', 28 | 'Update any user\'s status' => 'Aktualizuje status dowolnego użytkownika', 29 | ); 30 | -------------------------------------------------------------------------------- /views/default/_newpassword.php: -------------------------------------------------------------------------------- 1 |
2 | labelEx($model, 'newPassword'); ?> 3 | passwordField($model, 'newPassword', array('autocomplete' => 'off')); ?> 4 | error($model, 'newPassword'); ?> 5 | module->dicewareEnabled): ?> 6 | 7 | createUrl('password'); 9 | $diceLabel = Yii::t('UsrModule.usr', 'Use this password?\nTo copy it to the clipboard press Ctrl+C.'); 10 | $passwordId = CHtml::activeId($model, 'newPassword'); 11 | $verifyId = CHtml::activeId($model, 'newVerify'); 12 | $script = <<getClientScript()->registerScript(__CLASS__.'#diceware', $script); 25 | ?> 26 | 27 |
28 | 29 |
30 | labelEx($model, 'newVerify'); ?> 31 | passwordField($model, 'newVerify', array('autocomplete' => 'off')); ?> 32 | error($model, 'newVerify'); ?> 33 |
34 | -------------------------------------------------------------------------------- /migrations/m130701_104658_create_table_users.php: -------------------------------------------------------------------------------- 1 | createTable('{{users}}', array( 8 | 'id' => 'pk', 9 | 'username' => 'string NOT NULL', 10 | 'password' => 'string NOT NULL', 11 | 'email' => 'string NOT NULL', 12 | 'firstname' => 'string', 13 | 'lastname' => 'string', 14 | 'activation_key' => 'string', 15 | 'created_on' => 'timestamp', 16 | 'updated_on' => 'timestamp', 17 | 'last_visit_on' => 'timestamp', 18 | 'password_set_on' => 'timestamp', 19 | 'email_verified' => 'boolean NOT NULL DEFAULT 0', 20 | 'is_active' => 'boolean NOT NULL DEFAULT 0', 21 | 'is_disabled' => 'boolean NOT NULL DEFAULT 0', 22 | )); 23 | $this->createIndex('{{users}}_username_idx', '{{users}}', 'username', true); 24 | $this->createIndex('{{users}}_email_idx', '{{users}}', 'email', true); 25 | $this->createIndex('{{users}}_email_verified_idx', '{{users}}', 'email_verified'); 26 | $this->createIndex('{{users}}_is_active_idx', '{{users}}', 'is_active'); 27 | $this->createIndex('{{users}}_is_disabled_idx', '{{users}}', 'is_disabled'); 28 | } 29 | 30 | public function safeDown() 31 | { 32 | $this->dropTable('{{users}}'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /extensions/mailer/phpmailer/language/phpmailer.lang-ja.php: -------------------------------------------------------------------------------- 1 | 6 | */ 7 | 8 | $PHPMAILER_LANG['authenticate'] = 'שגיאת SMTP: פעולת האימות נכשלה.'; 9 | $PHPMAILER_LANG['connect_host'] = 'שגיאת SMTP: לא הצלחתי להתחבר לשרת SMTP.'; 10 | $PHPMAILER_LANG['data_not_accepted'] = 'שגיאת SMTP: מידע לא התקבל.'; 11 | $PHPMAILER_LANG['empty_message'] = 'גוף ההודעה ריק'; 12 | $PHPMAILER_LANG['invalid_address'] = 'כתובת שגויה'; 13 | $PHPMAILER_LANG['encoding'] = 'קידוד לא מוכר: '; 14 | $PHPMAILER_LANG['execute'] = 'לא הצלחתי להפעיל את: '; 15 | $PHPMAILER_LANG['file_access'] = 'לא ניתן לגשת לקובץ: '; 16 | $PHPMAILER_LANG['file_open'] = 'שגיאת קובץ: לא ניתן לגשת לקובץ: '; 17 | $PHPMAILER_LANG['from_failed'] = 'כתובות הנמענים הבאות נכשלו: '; 18 | $PHPMAILER_LANG['instantiate'] = 'לא הצלחתי להפעיל את פונקציית המייל.'; 19 | $PHPMAILER_LANG['mailer_not_supported'] = ' אינה נתמכת.'; 20 | $PHPMAILER_LANG['provide_address'] = 'חובה לספק לפחות כתובת אחת של מקבל המייל.'; 21 | $PHPMAILER_LANG['recipients_failed'] = 'שגיאת SMTP: הנמענים הבאים נכשלו: '; 22 | $PHPMAILER_LANG['signing'] = 'שגיאת חתימה: '; 23 | $PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.'; 24 | $PHPMAILER_LANG['smtp_error'] = 'שגיאת שרת SMTP: '; 25 | $PHPMAILER_LANG['variable_set'] = 'לא ניתן לקבוע או לשנות את המשתנה: '; 26 | -------------------------------------------------------------------------------- /components/IHybridauthIdentity.php: -------------------------------------------------------------------------------- 1 | breadcrumbs)) { 7 | $this->breadcrumbs = array($this->module->id, $title); 8 | } 9 | $this->pageTitle = Yii::app()->name.' - '.$title; 10 | ?> 11 |

12 | 13 | widget('usr.components.UsrAlerts', array('cssClassPrefix' => $this->module->alertCssClassPrefix)); ?> 14 | 15 |
16 | beginWidget($this->module->formClass, array( 17 | 'id' => 'login-form', 18 | 'enableClientValidation' => true, 19 | 'clientOptions' => array( 20 | 'validateOnSubmit' => true, 21 | ), 22 | 'focus' => array($model, 'newPassword'), 23 | 'action' => array('login', 'scenario' => 'reset'), 24 | )); ?> 25 | 26 |

* are required.'); ?>

27 | 28 | errorSummary($model); ?> 29 | 30 | hiddenField($model, 'username'); ?> 31 | hiddenField($model, 'password'); ?> 32 | hiddenField($model, 'rememberMe'); ?> 33 | 34 | renderPartial('_newpassword', array('form' => $form, 'model' => $model)); ?> 35 | 36 |
37 | $this->module->submitButtonCssClass)); ?> 38 |
39 | 40 | endWidget(); ?> 41 |
42 | -------------------------------------------------------------------------------- /extensions/mailer/phpmailer/language/phpmailer.lang-no.php: -------------------------------------------------------------------------------- 1 | 5 | */ 6 | 7 | $PHPMAILER_LANG['authenticate'] = 'SMTP klaida: autentifikacija nepavyko.'; 8 | $PHPMAILER_LANG['connect_host'] = 'SMTP klaida: nepavyksta prisijungti prie SMTP stoties.'; 9 | $PHPMAILER_LANG['data_not_accepted'] = 'SMTP klaida: duomenys nepriimti.'; 10 | $PHPMAILER_LANG['empty_message'] = 'Laiško turinys tuščias'; 11 | $PHPMAILER_LANG['encoding'] = 'Neatpažinta koduotė: '; 12 | $PHPMAILER_LANG['execute'] = 'Nepavyko įvykdyti komandos: '; 13 | $PHPMAILER_LANG['file_access'] = 'Byla nepasiekiama: '; 14 | $PHPMAILER_LANG['file_open'] = 'Bylos klaida: Nepavyksta atidaryti: '; 15 | $PHPMAILER_LANG['from_failed'] = 'Neteisingas siuntėjo adresas: '; 16 | $PHPMAILER_LANG['instantiate'] = 'Nepavyko paleisti mail funkcijos.'; 17 | $PHPMAILER_LANG['invalid_address'] = 'Neteisingas adresas'; 18 | $PHPMAILER_LANG['mailer_not_supported'] = ' pašto stotis nepalaikoma.'; 19 | $PHPMAILER_LANG['provide_address'] = 'Nurodykite bent vieną gavėjo adresą.'; 20 | $PHPMAILER_LANG['recipients_failed'] = 'SMTP klaida: nepavyko išsiųsti šiems gavėjams: '; 21 | $PHPMAILER_LANG['signing'] = 'Prisijungimo klaida: '; 22 | $PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP susijungimo klaida'; 23 | $PHPMAILER_LANG['smtp_error'] = 'SMTP stoties klaida: '; 24 | $PHPMAILER_LANG['variable_set'] = 'Nepavyko priskirti reikšmės kintamajam: '; 25 | -------------------------------------------------------------------------------- /extensions/mailer/phpmailer/language/phpmailer.lang-se.php: -------------------------------------------------------------------------------- 1 | 6 | */ 7 | 8 | $PHPMAILER_LANG['authenticate'] = 'SMTP fel: Kunde inte autentisera.'; 9 | $PHPMAILER_LANG['connect_host'] = 'SMTP fel: Kunde inte ansluta till SMTP-server.'; 10 | $PHPMAILER_LANG['data_not_accepted'] = 'SMTP fel: Data accepterades inte.'; 11 | //$PHPMAILER_LANG['empty_message'] = 'Message body empty'; 12 | $PHPMAILER_LANG['encoding'] = 'Okänt encode-format: '; 13 | $PHPMAILER_LANG['execute'] = 'Kunde inte köra: '; 14 | $PHPMAILER_LANG['file_access'] = 'Ingen åtkomst till fil: '; 15 | $PHPMAILER_LANG['file_open'] = 'Fil fel: Kunde inte öppna fil: '; 16 | $PHPMAILER_LANG['from_failed'] = 'Följande avsändaradress är felaktig: '; 17 | $PHPMAILER_LANG['instantiate'] = 'Kunde inte initiera e-postfunktion.'; 18 | //$PHPMAILER_LANG['invalid_address'] = 'Not sending, email address is invalid: '; 19 | $PHPMAILER_LANG['provide_address'] = 'Du måste ange minst en mottagares e-postadress.'; 20 | $PHPMAILER_LANG['mailer_not_supported'] = ' mailer stöds inte.'; 21 | $PHPMAILER_LANG['recipients_failed'] = 'SMTP fel: Följande mottagare är felaktig: '; 22 | //$PHPMAILER_LANG['signing'] = 'Signing Error: '; 23 | //$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.'; 24 | //$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: '; 25 | //$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: '; 26 | -------------------------------------------------------------------------------- /extensions/mailer/phpmailer/language/phpmailer.lang-dk.php: -------------------------------------------------------------------------------- 1 | 6 | */ 7 | 8 | $PHPMAILER_LANG['authenticate'] = 'SMTP fejl: Kunne ikke logge på.'; 9 | $PHPMAILER_LANG['connect_host'] = 'SMTP fejl: Kunne ikke tilslutte SMTP serveren.'; 10 | $PHPMAILER_LANG['data_not_accepted'] = 'SMTP fejl: Data kunne ikke accepteres.'; 11 | //$PHPMAILER_LANG['empty_message'] = 'Message body empty'; 12 | $PHPMAILER_LANG['encoding'] = 'Ukendt encode-format: '; 13 | $PHPMAILER_LANG['execute'] = 'Kunne ikke køre: '; 14 | $PHPMAILER_LANG['file_access'] = 'Ingen adgang til fil: '; 15 | $PHPMAILER_LANG['file_open'] = 'Fil fejl: Kunne ikke åbne filen: '; 16 | $PHPMAILER_LANG['from_failed'] = 'Følgende afsenderadresse er forkert: '; 17 | $PHPMAILER_LANG['instantiate'] = 'Kunne ikke initialisere email funktionen.'; 18 | //$PHPMAILER_LANG['invalid_address'] = 'Not sending, email address is invalid: '; 19 | $PHPMAILER_LANG['mailer_not_supported'] = ' mailer understøttes ikke.'; 20 | $PHPMAILER_LANG['provide_address'] = 'Du skal indtaste mindst en modtagers emailadresse.'; 21 | $PHPMAILER_LANG['recipients_failed'] = 'SMTP fejl: Følgende modtagere er forkerte: '; 22 | //$PHPMAILER_LANG['signing'] = 'Signing Error: '; 23 | //$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.'; 24 | //$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: '; 25 | //$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: '; 26 | -------------------------------------------------------------------------------- /extensions/mailer/phpmailer/language/phpmailer.lang-hu.php: -------------------------------------------------------------------------------- 1 | 6 | */ 7 | 8 | $PHPMAILER_LANG['authenticate'] = 'SMTP Error: Chyba autentifikácie.'; 9 | $PHPMAILER_LANG['connect_host'] = 'SMTP Error: Nebolo možné nadviazať spojenie so SMTP serverom.'; 10 | $PHPMAILER_LANG['data_not_accepted'] = 'SMTP Error: Dáta neboli prijaté'; 11 | $PHPMAILER_LANG['empty_message'] = 'Prázdne telo správy.'; 12 | $PHPMAILER_LANG['encoding'] = 'Neznáme kódovanie: '; 13 | $PHPMAILER_LANG['execute'] = 'Nedá sa vykonať: '; 14 | $PHPMAILER_LANG['file_access'] = 'Súbor nebol nájdený: '; 15 | $PHPMAILER_LANG['file_open'] = 'File Error: Súbor sa otvoriť pre čítanie: '; 16 | $PHPMAILER_LANG['from_failed'] = 'Následujúca adresa From je nesprávna: '; 17 | $PHPMAILER_LANG['instantiate'] = 'Nedá sa vytvoriť inštancia emailovej funkcie.'; 18 | $PHPMAILER_LANG['invalid_address'] = 'Neodoslané, emailová adresa je nesprávna: '; 19 | $PHPMAILER_LANG['mailer_not_supported'] = ' emailový klient nieje podporovaný.'; 20 | $PHPMAILER_LANG['provide_address'] = 'Musíte zadať aspoň jednu emailovú adresu príjemcu.'; 21 | $PHPMAILER_LANG['recipients_failed'] = 'SMTP Error: Adresy príjemcov niesu správne '; 22 | $PHPMAILER_LANG['signing'] = 'Chyba prihlasovania: '; 23 | $PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() zlyhalo.'; 24 | $PHPMAILER_LANG['smtp_error'] = 'SMTP chyba serveru: '; 25 | $PHPMAILER_LANG['variable_set'] = 'Nemožno nastaviť alebo resetovať premennú: '; 26 | -------------------------------------------------------------------------------- /extensions/mailer/phpmailer/language/phpmailer.lang-ar.php: -------------------------------------------------------------------------------- 1 | 6 | */ 7 | 8 | $PHPMAILER_LANG['authenticate'] = 'SMTP Error: لم نستطع تأكيد الهوية.'; 9 | $PHPMAILER_LANG['connect_host'] = 'SMTP Error: لم نستطع الاتصال بمخدم SMTP.'; 10 | $PHPMAILER_LANG['data_not_accepted'] = 'SMTP Error: لم يتم قبول المعلومات .'; 11 | //$PHPMAILER_LANG['empty_message'] = 'Message body empty'; 12 | $PHPMAILER_LANG['encoding'] = 'ترميز غير معروف: '; 13 | $PHPMAILER_LANG['execute'] = 'لم أستطع تنفيذ : '; 14 | $PHPMAILER_LANG['file_access'] = 'لم نستطع الوصول للملف: '; 15 | $PHPMAILER_LANG['file_open'] = 'File Error: لم نستطع فتح الملف: '; 16 | $PHPMAILER_LANG['from_failed'] = 'البريد التالي لم نستطع ارسال البريد له : '; 17 | $PHPMAILER_LANG['instantiate'] = 'لم نستطع توفير خدمة البريد.'; 18 | //$PHPMAILER_LANG['invalid_address'] = 'Not sending, email address is invalid: '; 19 | $PHPMAILER_LANG['mailer_not_supported'] = ' mailer غير مدعوم.'; 20 | //$PHPMAILER_LANG['provide_address'] = 'You must provide at least one recipient email address.'; 21 | $PHPMAILER_LANG['recipients_failed'] = 'SMTP Error: الأخطاء التالية ' . 22 | 'فشل في الارسال لكل من : '; 23 | $PHPMAILER_LANG['signing'] = 'خطأ في التوقيع: '; 24 | //$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.'; 25 | //$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: '; 26 | //$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: '; 27 | -------------------------------------------------------------------------------- /tests/config.php: -------------------------------------------------------------------------------- 1 | dirname(__FILE__).DIRECTORY_SEPARATOR.'..', 5 | 'name' => 'Widgets and Extensions demo', 6 | 'aliases' => array( 7 | 'vendors' => dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..', 8 | ), 9 | 'modules' => array( 10 | 'usr' => array( 11 | 'class' => 'vendors.nineinchnick.yii-usr.UsrModule', 12 | 'userIdentityClass' => 'UserIdentity', 13 | 'captcha' => array('clickableImage' => true,'showRefreshButton' => false), 14 | 'loginFormBehaviors' => array( 15 | 'expiredPasswordBehavior' => array( 16 | 'class' => 'ExpiredPasswordBehavior', 17 | 'passwordTimeout' => 10, 18 | ), 19 | 'oneTimePasswordBehavior' => array( 20 | 'class' => 'OneTimePasswordFormBehavior', 21 | 'mode' => 'time', // cannot use OneTimePasswordFormBehavior::OTP_TIME here as it hasn't been loaded yet 22 | 'required' => true, 23 | 'timeout' => 123, 24 | ), 25 | ), 26 | ), 27 | ), 28 | 'components' => array( 29 | 'db' => array( 30 | 'connectionString' => 'sqlite::memory:', 31 | 'initSQLs' => array('PRAGMA foreign_keys = ON'), 32 | //'connectionString' => 'mysql:host=localhost;dbname=test', 33 | 'tablePrefix' => 'tbl_', 34 | 'enableParamLogging' => true, 35 | ), 36 | 'fixture' => array( 37 | 'class' => 'system.test.CDbFixtureManager', 38 | ), 39 | ), 40 | ); 41 | -------------------------------------------------------------------------------- /extensions/mailer/phpmailer/language/phpmailer.lang-ca.php: -------------------------------------------------------------------------------- 1 | 5 | */ 6 | 7 | $PHPMAILER_LANG['authenticate'] = 'Помилка SMTP: помилка авторизації.'; 8 | $PHPMAILER_LANG['connect_host'] = 'Помилка SMTP: не вдається підєднатися до серверу SMTP.'; 9 | $PHPMAILER_LANG['data_not_accepted'] = 'Помилка SMTP: дані не прийняті.'; 10 | $PHPMAILER_LANG['encoding'] = 'Невідомий тип кодування: '; 11 | $PHPMAILER_LANG['execute'] = 'Неможливо виконати команду: '; 12 | $PHPMAILER_LANG['file_access'] = 'Немає доступу до файлу: '; 13 | $PHPMAILER_LANG['file_open'] = 'Помилка файлової системи: не вдається відкрити файл: '; 14 | $PHPMAILER_LANG['from_failed'] = 'Невірна адреса відправника: '; 15 | $PHPMAILER_LANG['instantiate'] = 'Неможливо запустити функцію mail.'; 16 | $PHPMAILER_LANG['provide_address'] = 'Будь-ласка, введіть хоча б одну адресу e-mail отримувача.'; 17 | $PHPMAILER_LANG['mailer_not_supported'] = ' - поштовий сервер не підтримується.'; 18 | $PHPMAILER_LANG['recipients_failed'] = 'Помилка SMTP: відправти наступним отрмувачам не вдалася: '; 19 | $PHPMAILER_LANG['empty_message'] = 'Пусте тіло повідомлення'; 20 | $PHPMAILER_LANG['invalid_address'] = 'Не відправлено, невірний формат email адреси: '; 21 | $PHPMAILER_LANG['signing'] = 'Помилка підпису: '; 22 | $PHPMAILER_LANG['smtp_connect_failed'] = 'Помилка зєднання із SMTP-сервером'; 23 | $PHPMAILER_LANG['smtp_error'] = 'Помилка SMTP-сервера: '; 24 | $PHPMAILER_LANG['variable_set'] = 'Неможливо встановити або перевстановити змінну: '; 25 | -------------------------------------------------------------------------------- /extensions/mailer/phpmailer/language/phpmailer.lang-ru.php: -------------------------------------------------------------------------------- 1 | 5 | */ 6 | 7 | $PHPMAILER_LANG['authenticate'] = 'Ошибка SMTP: ошибка авторизации.'; 8 | $PHPMAILER_LANG['connect_host'] = 'Ошибка SMTP: не удается подключиться к серверу SMTP.'; 9 | $PHPMAILER_LANG['data_not_accepted'] = 'Ошибка SMTP: данные не приняты.'; 10 | $PHPMAILER_LANG['encoding'] = 'Неизвестный вид кодировки: '; 11 | $PHPMAILER_LANG['execute'] = 'Невозможно выполнить команду: '; 12 | $PHPMAILER_LANG['file_access'] = 'Нет доступа к файлу: '; 13 | $PHPMAILER_LANG['file_open'] = 'Файловая ошибка: не удается открыть файл: '; 14 | $PHPMAILER_LANG['from_failed'] = 'Неверный адрес отправителя: '; 15 | $PHPMAILER_LANG['instantiate'] = 'Невозможно запустить функцию mail.'; 16 | $PHPMAILER_LANG['provide_address'] = 'Пожалуйста, введите хотя бы один адрес e-mail получателя.'; 17 | $PHPMAILER_LANG['mailer_not_supported'] = ' - почтовый сервер не поддерживается.'; 18 | $PHPMAILER_LANG['recipients_failed'] = 'Ошибка SMTP: отправка по следующим адресам получателей не удалась: '; 19 | $PHPMAILER_LANG['empty_message'] = 'Пустое тело сообщения'; 20 | $PHPMAILER_LANG['invalid_address'] = 'Не отослано, неправильный формат email адреса: '; 21 | $PHPMAILER_LANG['signing'] = 'Ошибка подписывания: '; 22 | $PHPMAILER_LANG['smtp_connect_failed'] = 'Ошибка соединения с SMTP-сервером'; 23 | $PHPMAILER_LANG['smtp_error'] = 'Ошибка SMTP-сервера: '; 24 | $PHPMAILER_LANG['variable_set'] = 'Невозможно установить или переустановить переменную: '; 25 | -------------------------------------------------------------------------------- /extensions/mailer/phpmailer/language/phpmailer.lang-et.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | 9 | $PHPMAILER_LANG['authenticate'] = 'SMTP Viga: Autoriseerimise viga.'; 10 | $PHPMAILER_LANG['connect_host'] = 'SMTP Viga: Ei õnnestunud luua ühendust SMTP serveriga.'; 11 | $PHPMAILER_LANG['data_not_accepted'] = 'SMTP Viga: Vigased andmed.'; 12 | $PHPMAILER_LANG['empty_message'] = 'Tühi kirja sisu'; 13 | $PHPMAILER_LANG["encoding"] = 'Tundmatu kodeering: '; 14 | $PHPMAILER_LANG['execute'] = 'Tegevus ebaõnnestus: '; 15 | $PHPMAILER_LANG['file_access'] = 'Pole piisavalt õiguseid järgneva faili avamiseks: '; 16 | $PHPMAILER_LANG['file_open'] = 'Faili Viga: Faili avamine ebaõnnestus: '; 17 | $PHPMAILER_LANG['from_failed'] = 'Järgnev saatja e-posti aadress on vigane: '; 18 | $PHPMAILER_LANG['instantiate'] = 'mail funktiooni käivitamine ebaõnnestus.'; 19 | $PHPMAILER_LANG['invalid_address'] = 'Saatmine peatatud, e-posti address vigane: '; 20 | $PHPMAILER_LANG['provide_address'] = 'Te peate määrama vähemalt ühe saaja e-posti aadressi.'; 21 | $PHPMAILER_LANG['mailer_not_supported'] = ' maileri tugi puudub.'; 22 | $PHPMAILER_LANG['recipients_failed'] = 'SMTP Viga: Järgnevate saajate e-posti aadressid on vigased: '; 23 | $PHPMAILER_LANG["signing"] = 'Viga allkirjastamisel: '; 24 | $PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() ebaõnnestus.'; 25 | $PHPMAILER_LANG['smtp_error'] = 'SMTP serveri viga: '; 26 | $PHPMAILER_LANG['variable_set'] = 'Ei õnnestunud määrata või lähtestada muutujat: '; 27 | -------------------------------------------------------------------------------- /extensions/mailer/phpmailer/language/phpmailer.lang-pl.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | 9 | $PHPMAILER_LANG['authenticate'] = 'Eroare SMTP: Nu a functionat autentificarea.'; 10 | $PHPMAILER_LANG['connect_host'] = 'Eroare SMTP: Nu m-am putut conecta la adresa SMTP.'; 11 | $PHPMAILER_LANG['data_not_accepted'] = 'Eroare SMTP: Continutul mailului nu a fost acceptat.'; 12 | //$PHPMAILER_LANG['empty_message'] = 'Message body empty'; 13 | $PHPMAILER_LANG['encoding'] = 'Encodare necunoscuta: '; 14 | $PHPMAILER_LANG['execute'] = 'Nu pot executa: '; 15 | $PHPMAILER_LANG['file_access'] = 'Nu pot accesa fisierul: '; 16 | $PHPMAILER_LANG['file_open'] = 'Eroare de fisier: Nu pot deschide fisierul: '; 17 | $PHPMAILER_LANG['from_failed'] = 'Urmatoarele adrese From au dat eroare: '; 18 | $PHPMAILER_LANG['instantiate'] = 'Nu am putut instantia functia mail.'; 19 | //$PHPMAILER_LANG['invalid_address'] = 'Not sending, email address is invalid: '; 20 | $PHPMAILER_LANG['mailer_not_supported'] = ' mailer nu este suportat.'; 21 | $PHPMAILER_LANG['provide_address'] = 'Trebuie sa adaugati cel putin un recipient (adresa de mail).'; 22 | $PHPMAILER_LANG['recipients_failed'] = 'Eroare SMTP: Urmatoarele adrese de mail au dat eroare: '; 23 | //$PHPMAILER_LANG['signing'] = 'Signing Error: '; 24 | //$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.'; 25 | //$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: '; 26 | //$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: '; 27 | -------------------------------------------------------------------------------- /extensions/mailer/phpmailer/language/phpmailer.lang-fo.php: -------------------------------------------------------------------------------- 1 | scenario == 'register' ? Yii::t('UsrModule.usr', 'Registration') : Yii::t('UsrModule.usr', 'User profile'); 8 | if (isset($this->breadcrumbs)) { 9 | $this->breadcrumbs = array($this->module->id, $title); 10 | } 11 | $this->pageTitle = Yii::app()->name.' - '.$title; 12 | ?> 13 |

14 | 15 | widget('usr.components.UsrAlerts', array('cssClassPrefix' => $this->module->alertCssClassPrefix)); ?> 16 | 17 |
18 | beginWidget($this->module->formClass, array( 19 | 'id' => 'profile-form', 20 | 'enableAjaxValidation' => true, 21 | 'enableClientValidation' => false, 22 | 'clientOptions' => array( 23 | 'validateOnSubmit' => true, 24 | ), 25 | 'htmlOptions' => array('enctype' => 'multipart/form-data'), 26 | 'focus' => array($model, 'username'), 27 | )); ?> 28 | 29 |

* are required.'); ?>

30 | 31 | errorSummary($model); ?> 32 | 33 | renderPartial('_form', array('form' => $form, 'model' => $model, 'passwordForm' => $passwordForm)); ?> 34 | 35 | asa('captcha') !== null): ?> 36 | renderPartial('_captcha', array('form' => $form, 'model' => $model)); ?> 37 | 38 | 39 |
40 | $this->module->submitButtonCssClass)); ?> 41 |
42 | 43 | endWidget(); ?> 44 |
45 | -------------------------------------------------------------------------------- /extensions/mailer/phpmailer/language/phpmailer.lang-fi.php: -------------------------------------------------------------------------------- 1 | , Stefano Sabatini 7 | */ 8 | 9 | $PHPMAILER_LANG['authenticate'] = 'SMTP Error: Impossibile autenticarsi.'; 10 | $PHPMAILER_LANG['connect_host'] = 'SMTP Error: Impossibile connettersi all\'host SMTP.'; 11 | $PHPMAILER_LANG['data_not_accepted'] = 'SMTP Error: Dati non accettati dal server.'; 12 | $PHPMAILER_LANG['empty_message'] = 'Il corpo del messaggio è vuoto'; 13 | $PHPMAILER_LANG['encoding'] = 'Codifica dei caratteri sconosciuta: '; 14 | $PHPMAILER_LANG['execute'] = 'Impossibile eseguire l\'operazione: '; 15 | $PHPMAILER_LANG['file_access'] = 'Impossibile accedere al file: '; 16 | $PHPMAILER_LANG['file_open'] = 'File Error: Impossibile aprire il file: '; 17 | $PHPMAILER_LANG['from_failed'] = 'I seguenti indirizzi mittenti hanno generato errore: '; 18 | $PHPMAILER_LANG['instantiate'] = 'Impossibile istanziare la funzione mail'; 19 | $PHPMAILER_LANG['invalid_address'] = 'Impossibile inviare, l\'indirizzo email non è valido: '; 20 | $PHPMAILER_LANG['provide_address'] = 'Deve essere fornito almeno un indirizzo ricevente'; 21 | $PHPMAILER_LANG['mailer_not_supported'] = 'Mailer non supportato'; 22 | $PHPMAILER_LANG['recipients_failed'] = 'SMTP Error: I seguenti indirizzi destinatari hanno generato un errore: '; 23 | $PHPMAILER_LANG['signing'] = 'Errore nella firma: '; 24 | $PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() fallita.'; 25 | $PHPMAILER_LANG['smtp_error'] = 'Errore del server SMTP: '; 26 | $PHPMAILER_LANG['variable_set'] = 'Impossibile impostare o resettare la variabile: '; 27 | -------------------------------------------------------------------------------- /views/hybridauth/login.php: -------------------------------------------------------------------------------- 1 | $remoteLogin->provider)); 5 | if (isset($this->breadcrumbs)) { 6 | $this->breadcrumbs = array($this->module->id, $title); 7 | } 8 | $this->pageTitle = Yii::app()->name.' - '.$title; 9 | 10 | ?> 11 |

12 | 13 | widget('usr.components.UsrAlerts', array('cssClassPrefix' => $this->module->alertCssClassPrefix)); ?> 14 | 15 |
16 | beginWidget($this->module->formClass, array( 17 | 'id' => 'remoteLogin-form', 18 | 'action' => array($this->action->id), 19 | 'enableClientValidation' => true, 20 | 'clientOptions' => array( 21 | 'validateOnSubmit' => true, 22 | ), 23 | 'focus' => $remoteLogin->requiresFilling() ? array($remoteLogin, 'openid_identifier') : null, 24 | )); ?> 25 | 26 | hiddenField($remoteLogin, 'provider'); ?> 27 | 28 |
29 |

* are required.'); ?>

30 | 31 | errorSummary($remoteLogin); ?> 32 | 33 |
34 | labelEx($remoteLogin, 'openid_identifier'); ?> 35 | textField($remoteLogin, 'openid_identifier'); ?> 36 | error($remoteLogin, 'openid_identifier'); ?> 37 |
38 | 39 |
40 | $this->module->submitButtonCssClass)); ?> 41 |
42 |
43 | 44 |
45 | endWidget(); ?> 46 | 47 | -------------------------------------------------------------------------------- /extensions/mailer/phpmailer/language/phpmailer.lang-br.php: -------------------------------------------------------------------------------- 1 | breadcrumbs)) { 10 | $this->breadcrumbs = array($this->module->id, $title); 11 | } 12 | $this->pageTitle = Yii::app()->name.' - '.$title; 13 | ?> 14 |

15 | 16 | widget('usr.components.UsrAlerts', array('cssClassPrefix' => $this->module->alertCssClassPrefix)); ?> 17 | 18 |
19 | beginWidget($this->module->formClass, array( 20 | 'id' => 'secret-form', 21 | 'enableClientValidation' => false, 22 | 'clientOptions' => array( 23 | 'validateOnSubmit' => false, 24 | ), 25 | 'focus' => array($model, 'code'), 26 | )); ?> 27 | 28 | errorSummary($model); ?> 29 | 30 |

31 | 32 |
33 |
34 |
35 | 36 |
37 | 38 |

39 | 40 |
41 | labelEx($model, 'oneTimePassword'); ?> 42 | textField($model, 'oneTimePassword'); ?> 43 | error($model, 'oneTimePassword'); ?> 44 |
45 | 46 |
47 | $this->module->submitButtonCssClass)); ?> 48 |
49 | 50 | endWidget(); ?> 51 |
52 | -------------------------------------------------------------------------------- /models/ExampleUserUsedPassword.php: -------------------------------------------------------------------------------- 1 | array(self::BELONGS_TO, 'User', 'user_id'), 43 | ); 44 | } 45 | 46 | /** 47 | * @inheritdoc 48 | */ 49 | public function attributeLabels() 50 | { 51 | return array( 52 | 'id' => Yii::t('models', 'ID'), 53 | 'user_id' => Yii::t('models', 'User'), 54 | 'password' => Yii::t('models', 'Password'), 55 | 'set_on' => Yii::t('models', 'Password Set On'), 56 | ); 57 | } 58 | 59 | /** 60 | * @param string $className active record class name. 61 | * @return UserUsedPassword the static model class 62 | */ 63 | public static function model($className = __CLASS__) 64 | { 65 | return parent::model($className); 66 | } 67 | 68 | /** 69 | * @param string $password password to validate 70 | * @return bool if password provided is valid for saved one 71 | */ 72 | public function verifyPassword($password) 73 | { 74 | return $this->password !== null && password_verify($password, $this->password); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /extensions/mailer/phpmailer/language/phpmailer.lang-nl.php: -------------------------------------------------------------------------------- 1 | 5 | */ 6 | 7 | $PHPMAILER_LANG['authenticate'] = 'SMTP-fout: authenticatie mislukt.';//SMTP Error: Could not authenticate. 8 | $PHPMAILER_LANG['connect_host'] = 'SMTP-fout: kon niet verbinden met SMTP-host.';//SMTP Error: Could not connect to SMTP host. 9 | $PHPMAILER_LANG['data_not_accepted'] = 'SMTP-fout: data niet geaccepteerd.';//SMTP Error: Data not accepted. 10 | $PHPMAILER_LANG['empty_message'] = 'Berichttekst is leeg';//Message body empty 11 | $PHPMAILER_LANG['encoding'] = 'Onbekende codering: ';//Unknown encoding: 12 | $PHPMAILER_LANG['execute'] = 'Kon niet uitvoeren: ';//Could not execute: 13 | $PHPMAILER_LANG['file_access'] = 'Kreeg geen toegang tot bestand: ';//Could not access file: 14 | $PHPMAILER_LANG['file_open'] = 'Bestandsfout: kon bestand niet openen: ';//File Error: Could not open file: 15 | $PHPMAILER_LANG['from_failed'] = 'Het volgende afzendersadres is mislukt: ';//The following From address failed: 16 | $PHPMAILER_LANG['instantiate'] = 'Kon mailfunctie niet initialiseren.';//Could not instantiate mail function. 17 | $PHPMAILER_LANG['invalid_address'] = 'Ongeldig adres';//Invalid address 18 | $PHPMAILER_LANG['mailer_not_supported'] = ' mailer wordt niet ondersteund.';// mailer is not supported. 19 | $PHPMAILER_LANG['provide_address'] = 'Er moet minstens één ontvanger worden opgegeven.';//You must provide at least one recipient email address. 20 | $PHPMAILER_LANG['recipients_failed'] = 'SMTP-fout: de volgende ontvangers zijn mislukt: ';//SMTP Error: The following recipients failed: 21 | $PHPMAILER_LANG['signing'] = 'Signeerfout: ';//Signing Error: 22 | $PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Verbinding mislukt.'; 23 | $PHPMAILER_LANG['smtp_error'] = 'SMTP-serverfout: ';//SMTP server error: 24 | $PHPMAILER_LANG['variable_set'] = 'Kan de volgende variablen niet instellen of resetten: ';//Cannot set or reset variable: 25 | -------------------------------------------------------------------------------- /views/default/viewProfile.php: -------------------------------------------------------------------------------- 1 | breadcrumbs)) { 7 | $this->breadcrumbs = array($this->module->id, $title); 8 | } 9 | $this->pageTitle = Yii::app()->name.' - '.$title; 10 | 11 | if (isset($this->module->loginFormBehaviors['oneTimePasswordBehavior'])) { 12 | $otp = $this->module->loginFormBehaviors['oneTimePasswordBehavior']; 13 | } 14 | ?> 15 |

true)); ?>

16 | 17 | widget('usr.components.UsrAlerts', array('cssClassPrefix' => $this->module->alertCssClassPrefix)); ?> 18 | 19 | 'twoStepAuth', 24 | 'type' => 'raw', 25 | 'label' => Yii::t('UsrModule.usr', 'Two step authentication'), 26 | 'value' => $model->getIdentity()->getOneTimePasswordSecret() === null ? CHtml::link(Yii::t('UsrModule.usr', 'Enable'), array('toggleOneTimePassword')) : CHtml::link(Yii::t('UsrModule.usr', 'Disable'), array('toggleOneTimePassword')), 27 | ); 28 | } 29 | if ($model->getIdentity() instanceof IPictureIdentity) { 30 | $picture = $model->getIdentity()->getPictureUrl(80, 80); 31 | $url = $picture['url']; 32 | unset($picture['url']); 33 | array_unshift($attributes, array( 34 | 'name' => 'picture', 35 | 'type' => 'raw', 36 | 'label' => Yii::t('UsrModule.usr', 'Profile picture'), 37 | 'value' => CHtml::image($url, Yii::t('UsrModule.usr', 'Profile picture'), $picture), 38 | )); 39 | } 40 | $this->widget($this->module->detailViewClass, array('data' => $model, 'attributes' => $attributes)); 41 | 42 | if ($this->module->hybridauthEnabled()) { 43 | echo '

'; 44 | $this->renderPartial('_login_remote', array('model' => $model)); 45 | echo '

'; 46 | } 47 | -------------------------------------------------------------------------------- /extensions/Hybrid/Providers/Foursquare.php: -------------------------------------------------------------------------------- 1 | api->api_base_url = "https://api.foursquare.com/v2/"; 24 | $this->api->authorize_url = "https://foursquare.com/oauth2/authenticate"; 25 | $this->api->token_url = "https://foursquare.com/oauth2/access_token"; 26 | 27 | $this->api->sign_token_name = "oauth_token"; 28 | } 29 | 30 | /** 31 | * load the user profile from the IDp api client 32 | */ 33 | function getUserProfile() 34 | { 35 | $data = $this->api->api( "users/self", "GET", array( "v" => "20120401" ) ); 36 | 37 | if ( ! isset( $data->response->user->id ) ){ 38 | throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 ); 39 | } 40 | 41 | $data = $data->response->user; 42 | 43 | $this->user->profile->identifier = $data->id; 44 | $this->user->profile->firstName = $data->firstName; 45 | $this->user->profile->lastName = $data->lastName; 46 | $this->user->profile->displayName = trim( $this->user->profile->firstName . " " . $this->user->profile->lastName ); 47 | $this->user->profile->photoURL = $data->photo; 48 | $this->user->profile->profileURL = "https://www.foursquare.com/user/" . $data->id; 49 | $this->user->profile->gender = $data->gender; 50 | $this->user->profile->city = $data->homeCity; 51 | $this->user->profile->email = $data->contact->email; 52 | $this->user->profile->emailVerified = $data->contact->email; 53 | 54 | return $this->user->profile; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /views/default/verifyOTP.php: -------------------------------------------------------------------------------- 1 | breadcrumbs)) { 7 | $this->breadcrumbs = array($this->module->id, $title); 8 | } 9 | $this->pageTitle = Yii::app()->name.' - '.$title; 10 | 11 | $otp = $model->asa('oneTimePasswordBehavior'); 12 | ?> 13 |

14 | 15 | widget('usr.components.UsrAlerts', array('cssClassPrefix' => $this->module->alertCssClassPrefix)); ?> 16 | 17 |
18 | beginWidget($this->module->formClass, array( 19 | 'id' => 'login-form', 20 | 'enableClientValidation' => true, 21 | 'clientOptions' => array( 22 | 'validateOnSubmit' => true, 23 | ), 24 | 'focus' => array($model, 'oneTimePassword'), 25 | 'action' => array('login', 'scenario' => 'verifyOTP'), 26 | )); ?> 27 | 28 |

* are required.'); ?>

29 | 30 | errorSummary($model); ?> 31 | 32 |

33 | mode === OneTimePasswordFormBehavior::OTP_TIME): ?> 34 |
35 | mode === OneTimePasswordFormBehavior::OTP_COUNTER): ?> 36 |
37 | 38 |

39 | 40 | hiddenField($model, 'username'); ?> 41 | hiddenField($model, 'password'); ?> 42 | hiddenField($model, 'rememberMe'); ?> 43 | 44 |
45 | labelEx($model, 'oneTimePassword'); ?> 46 | textField($model, 'oneTimePassword'); ?> 47 | error($model, 'oneTimePassword'); ?> 48 |
49 | 50 |
51 | $this->module->submitButtonCssClass)); ?> 52 |
53 | 54 | endWidget(); ?> 55 |
56 | -------------------------------------------------------------------------------- /views/default/recovery.php: -------------------------------------------------------------------------------- 1 | breadcrumbs)) { 7 | $this->breadcrumbs = array($this->module->id, $title); 8 | } 9 | $this->pageTitle = Yii::app()->name.' - '.$title; 10 | ?> 11 |

12 | 13 | widget('usr.components.UsrAlerts', array('cssClassPrefix' => $this->module->alertCssClassPrefix)); ?> 14 | 15 |
16 | beginWidget($this->module->formClass, array( 17 | 'id' => 'recovery-form', 18 | 'enableClientValidation' => true, 19 | 'clientOptions' => array( 20 | 'validateOnSubmit' => true, 21 | ), 22 | 'focus' => array($model, $model->scenario === 'reset' ? 'newPassword' : 'username'), 23 | )); ?> 24 | 25 |

* are required.'); ?>

26 | 27 | errorSummary($model); ?> 28 | 29 | scenario === 'reset'): ?> 30 | hiddenField($model, 'username'); ?> 31 | hiddenField($model, 'email'); ?> 32 | hiddenField($model, 'activationKey'); ?> 33 | 34 | renderPartial('_newpassword', array('form' => $form, 'model' => $model)); ?> 35 | 36 |
37 | labelEx($model, 'username'); ?> 38 | textField($model, 'username'); ?> 39 | error($model, 'username'); ?> 40 |
41 | 42 |
43 | labelEx($model, 'email'); ?> 44 | textField($model, 'email'); ?> 45 | error($model, 'email'); ?> 46 |
47 | 48 | asa('captcha') !== null): ?> 49 | renderPartial('_captcha', array('form' => $form, 'model' => $model)); ?> 50 | 51 | 52 | 53 |
54 | $this->module->submitButtonCssClass)); ?> 55 |
56 | 57 | endWidget(); ?> 58 |
59 | -------------------------------------------------------------------------------- /extensions/Hybrid/Logger.php: -------------------------------------------------------------------------------- 1 | format(DATE_ATOM); 32 | 33 | file_put_contents( 34 | Hybrid_Auth::$config["debug_file"], 35 | "DEBUG -- " . $_SERVER['REMOTE_ADDR'] . " -- " . $datetime . " -- " . $message . " -- " . print_r($object, true) . "\n", 36 | FILE_APPEND 37 | ); 38 | } 39 | } 40 | 41 | public static function info( $message ) 42 | { 43 | if( Hybrid_Auth::$config["debug_mode"] ){ 44 | $datetime = new DateTime(); 45 | $datetime = $datetime->format(DATE_ATOM); 46 | 47 | file_put_contents( 48 | Hybrid_Auth::$config["debug_file"], 49 | "INFO -- " . $_SERVER['REMOTE_ADDR'] . " -- " . $datetime . " -- " . $message . "\n", 50 | FILE_APPEND 51 | ); 52 | } 53 | } 54 | 55 | public static function error($message, $object = NULL) 56 | { 57 | if( Hybrid_Auth::$config["debug_mode"] ){ 58 | $datetime = new DateTime(); 59 | $datetime = $datetime->format(DATE_ATOM); 60 | 61 | file_put_contents( 62 | Hybrid_Auth::$config["debug_file"], 63 | "ERROR -- " . $_SERVER['REMOTE_ADDR'] . " -- " . $datetime . " -- " . $message . " -- " . print_r($object, true) . "\n", 64 | FILE_APPEND 65 | ); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /views/default/_form.php: -------------------------------------------------------------------------------- 1 | 7 | 8 |
9 | labelEx($model, 'username'); ?> 10 | textField($model, 'username'); ?> 11 | error($model, 'username'); ?> 12 |
13 | 14 |
15 | labelEx($model, 'email'); ?> 16 | textField($model, 'email'); ?> 17 | error($model, 'email'); ?> 18 |
19 | 20 | scenario !== 'register'): ?> 21 |
22 | labelEx($model, 'password'); ?> 23 | passwordField($model, 'password', array('autocomplete' => 'off')); ?> 24 | error($model, 'password'); ?> 25 |
26 | 27 | 28 | 29 | renderPartial('/default/_newpassword', array('form' => $form, 'model' => $passwordForm)); ?> 30 | 31 | 32 |
33 | labelEx($model, 'firstName'); ?> 34 | textField($model, 'firstName'); ?> 35 | error($model, 'firstName'); ?> 36 |
37 | 38 |
39 | labelEx($model, 'lastName'); ?> 40 | textField($model, 'lastName'); ?> 41 | error($model, 'lastName'); ?> 42 |
43 | 44 | getIdentity() instanceof IPictureIdentity && !empty($model->pictureUploadRules)): 45 | $picture = $model->getIdentity()->getPictureUrl(80, 80); 46 | if ($picture !== null) { 47 | $url = $picture['url']; 48 | unset($picture['url']); 49 | } 50 | ?> 51 |
52 | labelEx($model, 'picture'); ?> 53 |
54 | fileField($model, 'picture'); ?> 55 | error($model, 'picture'); ?> 56 |
57 |
58 | label($model, 'removePicture', array('label' => $form->checkBox($model, 'removePicture').$model->getAttributeLabel('removePicture'), 'class' => 'checkbox')); ?> 59 | error($model, 'removePicture'); ?> 60 |
61 | 62 | -------------------------------------------------------------------------------- /extensions/Hybrid/User_Profile.php: -------------------------------------------------------------------------------- 1 | set( "hauth_session.error.status" , 1 ); 23 | Hybrid_Auth::storage()->set( "hauth_session.error.message" , $message ); 24 | Hybrid_Auth::storage()->set( "hauth_session.error.code" , $code ); 25 | Hybrid_Auth::storage()->set( "hauth_session.error.trace" , $trace ); 26 | Hybrid_Auth::storage()->set( "hauth_session.error.previous", $previous ); 27 | } 28 | 29 | /** 30 | * clear the last error 31 | */ 32 | public static function clearError() 33 | { 34 | Hybrid_Logger::info( "Enter Hybrid_Error::clearError()" ); 35 | 36 | Hybrid_Auth::storage()->delete( "hauth_session.error.status" ); 37 | Hybrid_Auth::storage()->delete( "hauth_session.error.message" ); 38 | Hybrid_Auth::storage()->delete( "hauth_session.error.code" ); 39 | Hybrid_Auth::storage()->delete( "hauth_session.error.trace" ); 40 | Hybrid_Auth::storage()->delete( "hauth_session.error.previous" ); 41 | } 42 | 43 | /** 44 | * Checks to see if there is a an error. 45 | * 46 | * @return boolean True if there is an error. 47 | */ 48 | public static function hasError() 49 | { 50 | return (bool) Hybrid_Auth::storage()->get( "hauth_session.error.status" ); 51 | } 52 | 53 | /** 54 | * return error message 55 | */ 56 | public static function getErrorMessage() 57 | { 58 | return Hybrid_Auth::storage()->get( "hauth_session.error.message" ); 59 | } 60 | 61 | /** 62 | * return error code 63 | */ 64 | public static function getErrorCode() 65 | { 66 | return Hybrid_Auth::storage()->get( "hauth_session.error.code" ); 67 | } 68 | 69 | /** 70 | * return string detailled error backtrace as string. 71 | */ 72 | public static function getErrorTrace() 73 | { 74 | return Hybrid_Auth::storage()->get( "hauth_session.error.trace" ); 75 | } 76 | 77 | /** 78 | * @return string detailled error backtrace as string. 79 | */ 80 | public static function getErrorPrevious() 81 | { 82 | return Hybrid_Auth::storage()->get( "hauth_session.error.previous" ); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /models/ExampleUserProfilePicture.php: -------------------------------------------------------------------------------- 1 | array(self::BELONGS_TO, 'UserProfilePicture', 'original_picture_id'), 48 | 'thumbnails' => array(self::HAS_MANY, 'UserProfilePicture', 'original_picture_id'), 49 | 'user' => array(self::BELONGS_TO, 'Users', 'user_id'), 50 | ); 51 | } 52 | 53 | /** 54 | * @inheritdoc 55 | */ 56 | public function attributeLabels() 57 | { 58 | return array( 59 | 'id' => Yii::t('models', 'ID'), 60 | 'user_id' => Yii::t('models', 'User'), 61 | 'original_picture_id' => Yii::t('models', 'Original Picture'), 62 | 'filename' => Yii::t('models', 'Filename'), 63 | 'width' => Yii::t('models', 'Width'), 64 | 'height' => Yii::t('models', 'Height'), 65 | 'mimetype' => Yii::t('models', 'Mimetype'), 66 | 'created_on' => Yii::t('models', 'Created On'), 67 | 'contents' => Yii::t('models', 'Contents'), 68 | ); 69 | } 70 | 71 | /** 72 | * @param string $className active record class name. 73 | * @return UserProfilePicture the static model class 74 | */ 75 | public static function model($className = __CLASS__) 76 | { 77 | return parent::model($className); 78 | } 79 | 80 | protected function beforeSave() 81 | { 82 | if ($this->isNewRecord) { 83 | $this->created_on = date('Y-m-d H:i:s'); 84 | } 85 | 86 | return parent::beforeSave(); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /extensions/Hybrid/Storage.php: -------------------------------------------------------------------------------- 1 | config( "php_session_id", session_id() ); 22 | $this->config( "version", Hybrid_Auth::$version ); 23 | } 24 | 25 | public function config($key, $value=null) 26 | { 27 | $key = strtolower( $key ); 28 | 29 | if( $value ){ 30 | $_SESSION["HA::CONFIG"][$key] = serialize( $value ); 31 | } 32 | elseif( isset( $_SESSION["HA::CONFIG"][$key] ) ){ 33 | return unserialize( $_SESSION["HA::CONFIG"][$key] ); 34 | } 35 | 36 | return NULL; 37 | } 38 | 39 | public function get($key) 40 | { 41 | $key = strtolower( $key ); 42 | 43 | if( isset( $_SESSION["HA::STORE"], $_SESSION["HA::STORE"][$key] ) ){ 44 | return unserialize( $_SESSION["HA::STORE"][$key] ); 45 | } 46 | 47 | return NULL; 48 | } 49 | 50 | public function set( $key, $value ) 51 | { 52 | $key = strtolower( $key ); 53 | 54 | $_SESSION["HA::STORE"][$key] = serialize( $value ); 55 | } 56 | 57 | function clear() 58 | { 59 | $_SESSION["HA::STORE"] = ARRAY(); 60 | } 61 | 62 | function delete($key) 63 | { 64 | $key = strtolower( $key ); 65 | 66 | if( isset( $_SESSION["HA::STORE"], $_SESSION["HA::STORE"][$key] ) ){ 67 | $f = $_SESSION['HA::STORE']; 68 | unset($f[$key]); 69 | $_SESSION["HA::STORE"] = $f; 70 | } 71 | } 72 | 73 | function deleteMatch($key) 74 | { 75 | $key = strtolower( $key ); 76 | 77 | if( isset( $_SESSION["HA::STORE"] ) && count( $_SESSION["HA::STORE"] ) ) { 78 | $f = $_SESSION['HA::STORE']; 79 | foreach( $f as $k => $v ){ 80 | if( strstr( $k, $key ) ){ 81 | unset( $f[ $k ] ); 82 | } 83 | } 84 | $_SESSION["HA::STORE"] = $f; 85 | 86 | } 87 | } 88 | 89 | function getSessionData() 90 | { 91 | if( isset( $_SESSION["HA::STORE"] ) ){ 92 | return serialize( $_SESSION["HA::STORE"] ); 93 | } 94 | 95 | return NULL; 96 | } 97 | 98 | function restoreSessionData( $sessiondata = NULL ) 99 | { 100 | $_SESSION["HA::STORE"] = unserialize( $sessiondata ); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /messages/es/manager.php: -------------------------------------------------------------------------------- 1 | 'Activar', 21 | 'Active' => 'Activo', 22 | 'Advanced Search' => 'Búsqueda avanzada', 23 | 'Any' => 'Cualquiera', 24 | 'Authorization roles' => 'Roles de autorización', 25 | 'Create' => 'Crear', 26 | 'Create user' => 'Crear usuario', 27 | 'Created On' => 'Creado el', 28 | 'Deactivate' => 'Desactivar', 29 | 'Disable' => 'Deshabilitar', 30 | 'Disabled' => 'Deshabilitado', 31 | 'Email' => 'Correo electrónico', 32 | 'Email Verified' => 'Correo Electrónico Verificado', 33 | 'Enable' => 'Habilitar', 34 | 'Enabled' => 'Habilitado', 35 | 'Fields with {asterisk} are required.' => 'Los campos con {asterisk} son obligatorios.', 36 | 'Firstname' => 'Nombre', 37 | 'ID' => 'ID', 38 | 'Is Active' => 'Está activo', 39 | 'Is Disabled' => 'Está deshabilitado', 40 | 'Last Visit On' => 'Última visita', 41 | 'Lastname' => 'Apellido', 42 | 'List users' => 'Lista de usuarios', 43 | 'No' => 'No', 44 | 'Not active' => 'Inactivo', 45 | 'Password Set On' => 'Contraseña establecida', 46 | 'Save' => 'Guardar', 47 | 'Search' => 'Buscar', 48 | 'Toggle' => 'Cambiar', 49 | 'Unverified' => 'No verificado', 50 | 'Unverify' => 'anular la verificación', 51 | 'Update user {id}' => 'Actualizar usuario {id}', 52 | 'Updated On' => 'Actualizado', 53 | 'User account has been successfully created or updated.' => 'Cuenta de usuario se ha creado o actualizado correctamente.', 54 | 'Username' => 'Nombre de usuario', 55 | 'Verified' => 'Verificado', 56 | 'Verify' => 'Verificar', 57 | 'Yes' => 'Si', 58 | 'You may optionally enter a comparison operator (<, <=, >, >=, <> or =) at the beginning of each of your search values to specify how the comparison should be done.' => 'También puede escribir un operador de comparación (<, <=, >, >=, <> o =) al comienzo de cada uno de los valores de búsqueda para especificar cómo se debe hacer la comparación.', 59 | ); 60 | -------------------------------------------------------------------------------- /extensions/Hybrid/resources/config.php.tpl: -------------------------------------------------------------------------------- 1 | "#GLOBAL_HYBRID_AUTH_URL_BASE#", 15 | 16 | "providers" => array ( 17 | // openid providers 18 | "OpenID" => array ( 19 | "enabled" => #OPENID_ADAPTER_STATUS# 20 | ), 21 | 22 | "AOL" => array ( 23 | "enabled" => #AOL_ADAPTER_STATUS# 24 | ), 25 | 26 | "Yahoo" => array ( 27 | "enabled" => #YAHOO_ADAPTER_STATUS#, 28 | "keys" => array ( "id" => "#YAHOO_APPLICATION_APP_ID#", "secret" => "#YAHOO_APPLICATION_SECRET#" ) 29 | ), 30 | 31 | "Google" => array ( 32 | "enabled" => #GOOGLE_ADAPTER_STATUS#, 33 | "keys" => array ( "id" => "#GOOGLE_APPLICATION_APP_ID#", "secret" => "#GOOGLE_APPLICATION_SECRET#" ) 34 | ), 35 | 36 | "Facebook" => array ( 37 | "enabled" => #FACEBOOK_ADAPTER_STATUS#, 38 | "keys" => array ( "id" => "#FACEBOOK_APPLICATION_APP_ID#", "secret" => "#FACEBOOK_APPLICATION_SECRET#" ) 39 | ), 40 | 41 | "Twitter" => array ( 42 | "enabled" => #TWITTER_ADAPTER_STATUS#, 43 | "keys" => array ( "key" => "#TWITTER_APPLICATION_KEY#", "secret" => "#TWITTER_APPLICATION_SECRET#" ) 44 | ), 45 | 46 | // windows live 47 | "Live" => array ( 48 | "enabled" => #LIVE_ADAPTER_STATUS#, 49 | "keys" => array ( "id" => "#LIVE_APPLICATION_APP_ID#", "secret" => "#LIVE_APPLICATION_SECRET#" ) 50 | ), 51 | 52 | "MySpace" => array ( 53 | "enabled" => #MYSPACE_ADAPTER_STATUS#, 54 | "keys" => array ( "key" => "#MYSPACE_APPLICATION_KEY#", "secret" => "#MYSPACE_APPLICATION_SECRET#" ) 55 | ), 56 | 57 | "LinkedIn" => array ( 58 | "enabled" => #LINKEDIN_ADAPTER_STATUS#, 59 | "keys" => array ( "key" => "#LINKEDIN_APPLICATION_KEY#", "secret" => "#LINKEDIN_APPLICATION_SECRET#" ) 60 | ), 61 | 62 | "Foursquare" => array ( 63 | "enabled" => #FOURSQUARE_ADAPTER_STATUS#, 64 | "keys" => array ( "id" => "#FOURSQUARE_APPLICATION_APP_ID#", "secret" => "#FOURSQUARE_APPLICATION_SECRET#" ) 65 | ), 66 | ), 67 | 68 | // if you want to enable logging, set 'debug_mode' to true then provide a writable file by the web server on "debug_file" 69 | "debug_mode" => false, 70 | 71 | "debug_file" => "" 72 | ); 73 | -------------------------------------------------------------------------------- /views/manager/_search.php: -------------------------------------------------------------------------------- 1 | Yii::t('UsrModule.manager', 'Any'), 'separator' => '', 'labelOptions' => array('style' => 'display: inline; float: none;')); 8 | ?> 9 | 10 |
11 | 12 | beginWidget('CActiveForm', array( 13 | 'action' => Yii::app()->createUrl($this->route), 14 | 'method' => 'get', 15 | )); ?> 16 | 17 |
18 | label($model, 'id'); ?> 19 | textField($model, 'id'); ?> 20 |
21 | 22 |
23 | label($model, 'username'); ?> 24 | textField($model, 'username', array('size' => 60, 'maxlength' => 255)); ?> 25 |
26 | 27 |
28 | label($model, 'email'); ?> 29 | textField($model, 'email', array('size' => 60, 'maxlength' => 255)); ?> 30 |
31 | 32 |
33 | label($model, 'firstName'); ?> 34 | textField($model, 'firstName', array('size' => 60, 'maxlength' => 255)); ?> 35 |
36 | 37 |
38 | label($model, 'lastName'); ?> 39 | textField($model, 'lastName', array('size' => 60, 'maxlength' => 255)); ?> 40 |
41 | 42 |
43 | label($model, 'createdOn'); ?> 44 | textField($model, 'createdOn'); ?> 45 |
46 | 47 |
48 | label($model, 'updatedOn'); ?> 49 | textField($model, 'updatedOn'); ?> 50 |
51 | 52 |
53 | label($model, 'lastVisitOn'); ?> 54 | textField($model, 'lastVisitOn'); ?> 55 |
56 | 57 |
58 | label($model, 'emailVerified'); ?> 59 | radioButtonList($model, 'emailVerified', $booleanData, $booleanOptions); ?> 60 |
61 | 62 |
63 | label($model, 'isActive'); ?> 64 | radioButtonList($model, 'isActive', $booleanData, $booleanOptions); ?> 65 |
66 | 67 |
68 | label($model, 'isDisabled'); ?> 69 | radioButtonList($model, 'isDisabled', $booleanData, $booleanOptions); ?> 70 |
71 | 72 |
73 | 74 |
75 | 76 | endWidget(); ?> 77 | 78 |
79 | -------------------------------------------------------------------------------- /messages/pl/manager.php: -------------------------------------------------------------------------------- 1 | 'Aktywny', 21 | 'Advanced Search' => 'Szukanie zaawansowane', 22 | 'Any' => 'Dowolnie', 23 | 'Are you sure you want to delete this user?' => 'Na pewno usunąć tego użytkownika?', 24 | 'Authorization roles' => 'Profile uprawnień', 25 | 'Create' => 'Utwórz', 26 | 'Create user' => 'Utwórz użytkownika', 27 | 'Created On' => 'Utworzony dnia', 28 | 'Delete user {id}' => 'Usuń użytkownika {id}', 29 | 'Disabled' => 'Zablokowany', 30 | 'Enabled' => 'Odblokowany', 31 | 'Email' => 'Email', 32 | 'Email Verified' => 'Email zweryfikowany', 33 | 'Fields with {asterisk} are required.' => 'Pola oznaczone {asterisk} są wymagane.', 34 | 'Firstname' => 'Imię', 35 | 'Is Active' => 'Aktywny', 36 | 'Is Disabled' => 'Wyłączony', 37 | 'Last Visit On' => 'Ostatnia wizyta dnia', 38 | 'Lastname' => 'Nazwisko', 39 | 'List users' => 'Przeglądaj użytkowników', 40 | 'No' => 'Nie', 41 | 'Not active' => 'Nieaktywny', 42 | 'Password Set On' => 'Hasło ustawione dnia', 43 | 'Save' => 'Zapisz', 44 | 'Search' => 'Szukaj', 45 | 'Unverified' => 'Niezweryfikowany', 46 | 'Update' => 'Aktualizuj', 47 | 'Update user {id}' => 'Aktualizuj użytkownika {id}', 48 | 'Updated On' => 'Zaktualizowany dnia', 49 | 'User account has been successfully created or updated.' => 'Konto użytkownika zostało pomyślnie utworzone lub zaktualizowane.', 50 | 'Users manager' => 'Zarządzanie użytkownikami', 51 | 'Username' => 'Nazwa użytkownika', 52 | 'Verified' => 'Zweryfikowany', 53 | 'View user {id}' => 'Szczegóły użytkownika {id}', 54 | 'Yes' => 'Tak', 55 | 'You may optionally enter a comparison operator (<, <=, >, >=, <> or =) at the beginning of each of your search values to specify how the comparison should be done.' => 'Możesz poprzedzić każdą szukaną wartość opcjonalnym operatorem porównania (<, <=, >, >=, <> lub =).', 56 | 'User account has been successfully deleted.' => 'Konto użytkownika zostało usunięte pomyślnie.', 57 | 'User account could not be deleted.' => 'Nie można usunąć konta użytkownika.', 58 | ); 59 | -------------------------------------------------------------------------------- /tests/unit/PasswordFormTest.php: -------------------------------------------------------------------------------- 1 | 'User', 12 | ); 13 | 14 | public static function validDataProvider() 15 | { 16 | return array( 17 | array( 18 | 'scenario' => '', 19 | 'attributes' => array( 20 | 'password' => 'Test1233', 21 | 'newPassword' => 'Test1234', 22 | 'newVerify' => 'Test1234', 23 | ), 24 | ), 25 | ); 26 | } 27 | 28 | public static function invalidDataProvider() 29 | { 30 | return array( 31 | array( 32 | 'scenario' => '', 33 | 'attributes' => array( 34 | 'password' => 'xx', 35 | 'newPassword' => 'oo', 36 | 'newPasswordVerify' => 'oo', 37 | ), 38 | 'errors ' => array( 39 | 'password' => array('Invalid password.'), 40 | 'newVerify' => array('Verify cannot be blank.', 'Please type the same new password twice to verify it.'), 41 | 'newPassword' => array('New password is too short (minimum is 8 characters).', 'New password must contain at least one lower and upper case character and a digit.'), 42 | ), 43 | ), 44 | ); 45 | } 46 | 47 | public static function allDataProvider() 48 | { 49 | return array_merge(self::validDataProvider(), self::invalidDataProvider()); 50 | } 51 | 52 | /** 53 | * @dataProvider validDataProvider 54 | */ 55 | public function testValid($scenario, $attributes) 56 | { 57 | $form = new PasswordForm($scenario); 58 | $form->userIdentityClass = 'UserIdentity'; 59 | $form->setIdentity(new UserIdentity('neo', 'Test1233')); 60 | $form->setAttributes($attributes); 61 | $this->assertTrue($form->validate(), 'Failed with following validation errors: '.print_r($form->getErrors(), true)); 62 | $this->assertEmpty($form->getErrors()); 63 | } 64 | 65 | /** 66 | * @dataProvider invalidDataProvider 67 | */ 68 | public function testInvalid($scenario, $attributes, $errors) 69 | { 70 | $form = new PasswordForm($scenario); 71 | $form->userIdentityClass = 'UserIdentity'; 72 | $form->setIdentity(new UserIdentity('neo', 'Test1233')); 73 | $form->setAttributes($attributes); 74 | $this->assertFalse($form->validate()); 75 | $this->assertEquals($errors, $form->getErrors()); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /components/ExpiredPasswordBehavior.php: -------------------------------------------------------------------------------- 1 | 6 | */ 7 | 8 | /** 9 | * ExpiredPasswordBehavior adds captcha validation to a form model component. 10 | * The model should extend from {@link CFormModel} or its child classes. 11 | * 12 | * The user identity class must implement IPasswordHistoryIdentity interface. 13 | * 14 | * @property CFormModel $owner The owner model that this behavior is attached to. 15 | * @property integer $passwordTimeout Number of days after which user is requred to reset his password after logging in. 16 | * 17 | * @author Jan Was 18 | */ 19 | class ExpiredPasswordBehavior extends FormModelBehavior 20 | { 21 | private $_passwordTimeout; 22 | 23 | /** 24 | * @return integer Number of days after which user is requred to reset his password after logging in. 25 | */ 26 | public function getPasswordTimeout() 27 | { 28 | return $this->_passwordTimeout; 29 | } 30 | 31 | /** 32 | * @param $value integer Number of days after which user is requred to reset his password after logging in. 33 | */ 34 | public function setPasswordTimeout($value) 35 | { 36 | $this->_passwordTimeout = $value; 37 | } 38 | 39 | /** 40 | * @inheritdoc 41 | */ 42 | public function filterRules($rules = array()) 43 | { 44 | $behaviorRules = array( 45 | array('password', 'passwordHasNotExpired', 'except' => 'reset, hybridauth, verifyOTP'), 46 | ); 47 | 48 | return array_merge($rules, $this->applyRuleOptions($behaviorRules)); 49 | } 50 | 51 | public function passwordHasNotExpired() 52 | { 53 | if ($this->owner->hasErrors()) { 54 | return; 55 | } 56 | 57 | $identity = $this->owner->getIdentity(); 58 | if (!($identity instanceof IPasswordHistoryIdentity)) { 59 | throw new CException(Yii::t('UsrModule.usr', 'The {class} class must implement the {interface} interface.', array('{class}' => get_class($identity), '{interface}' => 'IPasswordHistoryIdentity'))); 60 | } 61 | $lastUsed = $identity->getPasswordDate(); 62 | $lastUsedDate = new DateTime($lastUsed); 63 | $today = new DateTime(); 64 | if ($lastUsed === null || $today->diff($lastUsedDate)->days >= $this->passwordTimeout) { 65 | if ($lastUsed === null) { 66 | $this->owner->addError('password', Yii::t('UsrModule.usr', 'This is the first time you login. Current password needs to be changed.')); 67 | } else { 68 | $this->owner->addError('password', Yii::t('UsrModule.usr', 'Current password has been used too long and needs to be changed.')); 69 | } 70 | $this->owner->scenario = 'reset'; 71 | 72 | return false; 73 | } 74 | 75 | return true; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /models/ExampleUserRemoteIdentity.php: -------------------------------------------------------------------------------- 1 | true), 35 | array('provider, identifier', 'length', 'max' => 100), 36 | array('user_id', 'isUnique'), 37 | ); 38 | } 39 | 40 | /** 41 | * An inline validator that checkes if there are no existing records 42 | * with same provider and identifier for specified user. 43 | * @param string $attribute 44 | * @param array $params 45 | * @return boolean 46 | */ 47 | public function isUnique($attribute, $params) 48 | { 49 | return 0 === $this->countByAttributes(array( 50 | 'user_id' => $this->user_id, 51 | 'provider' => $this->provider, 52 | 'identifier' => $this->identifier, 53 | )); 54 | } 55 | 56 | /** 57 | * @return array relational rules. 58 | */ 59 | public function relations() 60 | { 61 | return array( 62 | 'user' => array(self::BELONGS_TO, 'User', 'user_id'), 63 | ); 64 | } 65 | 66 | /** 67 | * @inheritdoc 68 | */ 69 | public function attributeLabels() 70 | { 71 | return array( 72 | 'id' => Yii::t('models', 'ID'), 73 | 'user_id' => Yii::t('models', 'User'), 74 | 'provider' => Yii::t('models', 'Provider'), 75 | 'identifier' => Yii::t('models', 'Identifier'), 76 | 'created_on' => Yii::t('models', 'Created On'), 77 | 'last_used_on' => Yii::t('models', 'Last Used On'), 78 | ); 79 | } 80 | 81 | /** 82 | * @param string $className active record class name. 83 | * @return UserRemoteIdentity the static model class 84 | */ 85 | public static function model($className = __CLASS__) 86 | { 87 | return parent::model($className); 88 | } 89 | 90 | protected function beforeSave() 91 | { 92 | if ($this->isNewRecord) { 93 | $this->created_on = date('Y-m-d H:i:s'); 94 | } 95 | 96 | return parent::beforeSave(); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /views/default/login.php: -------------------------------------------------------------------------------- 1 | breadcrumbs)) { 7 | $this->breadcrumbs = array($this->module->id, $title); 8 | } 9 | $this->pageTitle = Yii::app()->name.' - '.$title; 10 | ?> 11 |

12 | 13 | widget('usr.components.UsrAlerts', array('cssClassPrefix' => $this->module->alertCssClassPrefix)); ?> 14 | 15 |
16 | beginWidget($this->module->formClass, array( 17 | 'id' => 'login-form', 18 | 'enableClientValidation' => true, 19 | 'clientOptions' => array( 20 | 'validateOnSubmit' => true, 21 | ), 22 | 'focus' => array($model, 'username'), 23 | )); ?> 24 | 25 |

* are required.'); ?>

26 | 27 | errorSummary($model); ?> 28 | 29 |
30 | labelEx($model, 'username'); ?> 31 | textField($model, 'username'); ?> 32 | error($model, 'username'); ?> 33 |
34 | 35 |
36 | labelEx($model, 'password'); ?> 37 | passwordField($model, 'password'); ?> 38 | error($model, 'password'); ?> 39 |
40 | 41 | module->rememberMeDuration > 0): ?> 42 |
43 | label($model, 'rememberMe', array('label' => $form->checkBox($model, 'rememberMe').$model->getAttributeLabel('rememberMe'), 'class' => 'checkbox')); ?> 44 | error($model, 'rememberMe'); ?> 45 |
46 | 47 | 48 |
49 | $this->module->submitButtonCssClass)); ?> 50 |
51 | module->recoveryEnabled): ?> 52 |

53 | 54 | CHtml::link(Yii::t('UsrModule.usr', 'password recovery'), array('recovery')), 56 | )); ?> 57 |

58 | 59 | module->registrationEnabled): ?> 60 |

61 | 62 | CHtml::link(Yii::t('UsrModule.usr', 'registration'), array('register')), 64 | )); ?> 65 |

66 | 67 | module->hybridauthEnabled()): ?> 68 |

69 | 70 | renderPartial('_login_remote'); ?> 71 |

72 | 73 | 74 | endWidget(); ?> 75 |
76 | -------------------------------------------------------------------------------- /extensions/GoogleAuthenticator.php/lib/GoogleAuthenticator.php: -------------------------------------------------------------------------------- 1 | getCode($secret,$time + $i) == $code) { 32 | return true; 33 | } 34 | } 35 | 36 | return false; 37 | 38 | } 39 | 40 | public function getCode($secret,$time = null) { 41 | 42 | if ($time === null) { 43 | $time = floor(time() / 30); 44 | } 45 | $base32 = new FixedBitNotation(5, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567', TRUE, TRUE); 46 | $secret = $base32->decode($secret); 47 | 48 | $time = pack("N", $time); 49 | $time = str_pad($time,8, chr(0), STR_PAD_LEFT); 50 | 51 | $hash = hash_hmac('sha1',$time,$secret,true); 52 | $offset = ord(substr($hash,-1)); 53 | $offset = $offset & 0xF; 54 | 55 | $truncatedHash = self::hashToInt($hash, $offset) & 0x7FFFFFFF; 56 | $pinValue = str_pad($truncatedHash % self::$PIN_MODULO,6,"0",STR_PAD_LEFT);; 57 | return $pinValue; 58 | } 59 | 60 | protected function hashToInt($bytes, $start) { 61 | $input = substr($bytes, $start, strlen($bytes) - $start); 62 | $val2 = unpack("N",substr($input,0,4)); 63 | return $val2[1]; 64 | } 65 | 66 | public function getUrl($user, $hostname, $secret) { 67 | $url = sprintf("otpauth://totp/%s@%s?secret=%s", $user, $hostname, $secret); 68 | $encoder = "https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl="; 69 | $encoderURL = sprintf( "%sotpauth://totp/%s@%s&secret=%s",$encoder, $user, $hostname, $secret); 70 | 71 | return $encoderURL; 72 | 73 | } 74 | 75 | public function generateSecret() { 76 | $secret = ""; 77 | for($i = 1; $i<= self::$SECRET_LENGTH;$i++) { 78 | $c = rand(0,255); 79 | $secret .= pack("c",$c); 80 | } 81 | $base32 = new FixedBitNotation(5, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567', TRUE, TRUE); 82 | return $base32->encode($secret); 83 | 84 | 85 | } 86 | 87 | } 88 | 89 | -------------------------------------------------------------------------------- /views/default/_login_remote.php: -------------------------------------------------------------------------------- 1 | clientScript->registerCssFile(Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias($this->module->id.'.components.assets.zocial')).'/zocial.css'); 26 | Yii::app()->clientScript->registerScript(__CLASS__.'#popup', $popupScript, CClientScript::POS_END); 27 | ?> 28 | 51 | -------------------------------------------------------------------------------- /components/FormModelBehavior.php: -------------------------------------------------------------------------------- 1 | 6 | */ 7 | 8 | /** 9 | * FormModelBehavior is a base class for behaviors that are attached to a form model component. 10 | * The model should extend from {@link CFormModel} or its child classes. 11 | * 12 | * @property CFormModel $owner The owner model that this behavior is attached to. 13 | * 14 | * @author Jan Was 15 | */ 16 | abstract class FormModelBehavior extends CModelBehavior 17 | { 18 | private static $_names = array(); 19 | 20 | private $_ruleOptions = array(); 21 | 22 | /** 23 | * Adds validation rules for attributes of this behavior or removes rules from the owner model. 24 | * @return array validation rules 25 | * @see CModel::rules() 26 | */ 27 | public function filterRules($rules = array()) 28 | { 29 | return $rules; 30 | } 31 | 32 | /** 33 | * Labels for attributes of this behavior, that should be merged with labels in the owner model. 34 | * @return array attribute labels (name => label) 35 | * @see CModel::attributeLabels() 36 | */ 37 | public function attributeLabels() 38 | { 39 | return array(); 40 | } 41 | 42 | /** 43 | * Returns the list of attribute names. 44 | * By default, this method returns all public non-static properties of the class. 45 | * You may override this method to change the default behavior. 46 | * @return array list of attribute names. 47 | */ 48 | public function attributeNames() 49 | { 50 | $className = get_class($this); 51 | if (!isset(self::$_names[$className])) { 52 | $class = new ReflectionClass(get_class($this)); 53 | $names = array(); 54 | foreach ($class->getProperties() as $property) { 55 | $name = $property->getName(); 56 | if ($property->isPublic() && !$property->isStatic()) { 57 | $names[] = $name; 58 | } 59 | } 60 | 61 | return self::$_names[$className] = $names; 62 | } else { 63 | return self::$_names[$className]; 64 | } 65 | } 66 | 67 | /** 68 | * Lists valid model scenarios. 69 | * @return array 70 | */ 71 | public function getAvailableScenarios() 72 | { 73 | return array(); 74 | } 75 | 76 | /** 77 | * Adds current rule options to the given set of rules. 78 | * @param array $rules 79 | * @return array 80 | */ 81 | public function applyRuleOptions($rules) 82 | { 83 | foreach ($rules as $key => $rule) { 84 | foreach ($this->_ruleOptions as $name => $value) { 85 | $rules[$key][$name] = $value; 86 | } 87 | } 88 | 89 | return $rules; 90 | } 91 | 92 | /** 93 | * @return array 94 | */ 95 | public function getRuleOptions() 96 | { 97 | return $this->_ruleOptions; 98 | } 99 | 100 | /** 101 | * @param $value array 102 | */ 103 | public function setRuleOptions(array $value) 104 | { 105 | $this->_ruleOptions = $value; 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /controllers/UsrController.php: -------------------------------------------------------------------------------- 1 | module->mailer; 15 | $mail->AddAddress($model->getIdentity()->getEmail(), $model->getIdentity()->getName()); 16 | $params = array( 17 | 'siteUrl' => $this->createAbsoluteUrl('/'), 18 | ); 19 | switch ($mode) { 20 | default: return false; 21 | case 'recovery': 22 | case 'verify': 23 | $mail->Subject = $mode == 'recovery' ? Yii::t('UsrModule.usr', 'Password recovery') : Yii::t('UsrModule.usr', 'Email address verification'); 24 | $params['actionUrl'] = $this->createAbsoluteUrl('default/'.$mode, array( 25 | 'activationKey' => $model->getIdentity()->getActivationKey(), 26 | 'username' => $model->getIdentity()->getName(), 27 | )); 28 | break; 29 | case 'oneTimePassword': 30 | $mail->Subject = Yii::t('UsrModule.usr', 'One Time Password'); 31 | $params['code'] = $model->getNewCode(); 32 | break; 33 | } 34 | $body = $this->renderPartial($mail->getPathViews().'.'.$mode, $params, true); 35 | $full = $this->renderPartial($mail->getPathLayouts().'.email', array('content' => $body), true); 36 | $mail->MsgHTML($full); 37 | if ($mail->Send()) { 38 | return true; 39 | } else { 40 | Yii::log($mail->ErrorInfo, 'error'); 41 | 42 | return false; 43 | } 44 | } 45 | 46 | /** 47 | * Retreive view name and params based on scenario name and module configuration. 48 | * 49 | * @param string $scenario 50 | * @param string $default default view name if scenario is null 51 | * @return array two values, view name (string) and view params (array) 52 | */ 53 | public function getScenarioView($scenario, $default) 54 | { 55 | if (empty($scenario)) { 56 | $scenario = $default; 57 | } 58 | if (!isset($this->module->scenarioViews[$scenario])) { 59 | return array($scenario, array()); 60 | } 61 | // config, scenario, default 62 | $config = $this->module->scenarioViews[$scenario]; 63 | if (isset($config['view'])) { 64 | $view = $config['view']; 65 | unset($config['view']); 66 | } else { 67 | $view = $scenario; 68 | } 69 | 70 | return array($view, $config); 71 | } 72 | 73 | /** 74 | * Redirects user either to returnUrl or main page. 75 | */ 76 | public function afterLogin() 77 | { 78 | $returnUrl = Yii::app()->user->returnUrl; 79 | $returnUrlParts = explode('/', is_array($returnUrl) ? reset($returnUrl) : $returnUrl); 80 | $url = end($returnUrlParts) == 'index.php' ? '/' : Yii::app()->user->returnUrl; 81 | $this->redirect($url); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /views/hybridauth/confirm.php: -------------------------------------------------------------------------------- 1 | breadcrumbs)) { 6 | $this->breadcrumbs = array($this->module->id, $title); 7 | } 8 | $this->pageTitle = Yii::app()->name.' - '.$title; 9 | ?> 10 |

11 | 12 | widget('usr.components.UsrAlerts', array('cssClassPrefix' => $this->module->alertCssClassPrefix)); ?> 13 | 14 | module->registrationEnabled): ?> 15 | 16 |
17 | beginWidget($this->module->formClass, array( 18 | 'id' => 'localProfile-form', 19 | 'action' => array($this->action->id), 20 | 'enableClientValidation' => true, 21 | 'clientOptions' => array( 22 | 'validateOnSubmit' => true, 23 | ), 24 | 'focus' => array($localProfile, 'username'), 25 | )); ?> 26 | 27 | hiddenField($remoteLogin, 'provider'); ?> 28 | hiddenField($remoteLogin, 'openid_identifier'); ?> 29 | 30 |
31 |

32 | 33 |
34 | 'ProfileForm[continue]', 'class' => $this->module->submitButtonCssClass)); ?> 35 |
36 |
37 | 38 | endWidget(); ?> 39 |
40 | 41 | 42 | 43 |
44 | beginWidget($this->module->formClass, array( 45 | 'id' => 'localLogin-form', 46 | 'action' => array($this->action->id), 47 | 'enableClientValidation' => true, 48 | 'clientOptions' => array( 49 | 'validateOnSubmit' => true, 50 | ), 51 | 'focus' => array($localLogin, 'username'), 52 | )); ?> 53 | 54 | hiddenField($remoteLogin, 'provider'); ?> 55 | hiddenField($remoteLogin, 'openid_identifier'); ?> 56 | 57 |
58 |

59 | 60 |

61 | 62 | errorSummary($localLogin); ?> 63 | 64 | scenario != 'reset'): ?> 65 |
66 | labelEx($localLogin, 'password'); ?> 67 | passwordField($localLogin, 'password'); ?> 68 | error($localLogin, 'password'); ?> 69 |
70 | 71 |
72 | $this->module->submitButtonCssClass)); ?> 73 |
74 | 75 | hiddenField($localLogin, 'username'); ?> 76 | hiddenField($localLogin, 'password'); ?> 77 | hiddenField($localLogin, 'rememberMe'); ?> 78 | 79 | renderPartial('_newpassword', array('form' => $form, 'model' => $localLogin)); ?> 80 | 81 |
82 | $this->module->submitButtonCssClass)); ?> 83 |
84 | 85 |
86 | endWidget(); ?> 87 |
88 | -------------------------------------------------------------------------------- /models/PasswordForm.php: -------------------------------------------------------------------------------- 1 | 'trim', 'except' => 'register'), 23 | array('password', 'required', 'except' => 'register'), 24 | array('password', 'authenticate', 'except' => 'register'), 25 | ), parent::rules()); 26 | 27 | return $rules; 28 | } 29 | 30 | /** 31 | * Declares attribute labels. 32 | */ 33 | public function attributeLabels() 34 | { 35 | return array_merge(parent::attributeLabels(), array( 36 | 'password' => Yii::t('UsrModule.usr', 'Current password'), 37 | )); 38 | } 39 | 40 | /** 41 | * @inheritdoc 42 | */ 43 | public function getIdentity() 44 | { 45 | if ($this->_identity === null) { 46 | if ($this->scenario === 'register') { 47 | return $this->_identity; 48 | } 49 | $userIdentityClass = $this->userIdentityClass; 50 | $this->_identity = $userIdentityClass::find(array('id' => Yii::app()->user->getId())); 51 | } 52 | 53 | return $this->_identity; 54 | } 55 | 56 | public function setIdentity($identity) 57 | { 58 | $this->_identity = $identity; 59 | } 60 | 61 | /** 62 | * Authenticates the password. 63 | * This is the 'authenticate' validator as declared in rules(). 64 | */ 65 | public function authenticate($attribute, $params) 66 | { 67 | if ($this->hasErrors()) { 68 | return; 69 | } 70 | if (($identity = $this->getIdentity()) === null) { 71 | throw new CException('Current user has not been found in the database.'); 72 | } 73 | $identity->password = $this->password; 74 | if (!$identity->authenticate()) { 75 | $this->addError('password', Yii::t('UsrModule.usr', 'Invalid password.')); 76 | 77 | return false; 78 | } 79 | 80 | return true; 81 | } 82 | 83 | /** 84 | * Resets user password using the new one given in the model. 85 | * @return boolean whether password reset was successful 86 | */ 87 | public function resetPassword($identity = null) 88 | { 89 | if ($this->hasErrors()) { 90 | return; 91 | } 92 | if ($identity === null) { 93 | $identity = $this->getIdentity(); 94 | } 95 | $identity->password = $this->password; 96 | if (($message = $identity->resetPassword($this->newPassword)) !== true) { 97 | $this->addError('newPassword', is_string($message) ? $message : Yii::t('UsrModule.usr', 'Failed to reset the password.')); 98 | 99 | return false; 100 | } 101 | 102 | return true; 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /tests/unit/RecoveryFormTest.php: -------------------------------------------------------------------------------- 1 | 'User', 12 | ); 13 | 14 | public static function validDataProvider() 15 | { 16 | return array( 17 | array( 18 | 'scenario' => '', 19 | 'attributes' => array( 20 | 'username' => 'neo', 21 | 'email' => 'neo@matrix.com', 22 | ), 23 | ), 24 | ); 25 | } 26 | 27 | public static function invalidDataProvider() 28 | { 29 | return array( 30 | array( 31 | 'scenario' => '', 32 | 'attributes' => array( 33 | 'username' => 'trin', 34 | 'email' => 'trinity@matrix.com', 35 | ), 36 | 'errors ' => array( 37 | 'username' => array('No user found matching this username.'), 38 | ), 39 | ), 40 | ); 41 | } 42 | 43 | public static function allDataProvider() 44 | { 45 | return array_merge(self::validDataProvider(), self::invalidDataProvider()); 46 | } 47 | 48 | public function testWithBehavior() 49 | { 50 | $form = new RecoveryForm(); 51 | $formAttributes = $form->attributeNames(); 52 | $formRules = $form->rules(); 53 | $formLabels = $form->attributeLabels(); 54 | $form->attachBehavior('captcha', array('class' => 'CaptchaFormBehavior')); 55 | $behaviorAttributes = $form->asa('captcha')->attributeNames(); 56 | $behaviorRules = $form->asa('captcha')->filterRules(); 57 | $behaviorLabels = $form->asa('captcha')->attributeLabels(); 58 | $this->assertEquals(array_merge($formAttributes, $behaviorAttributes), $form->attributeNames()); 59 | $this->assertEquals(array_merge($behaviorRules, $formRules), $form->rules()); 60 | $this->assertEquals(array_merge($formLabels, $behaviorLabels), $form->attributeLabels()); 61 | $form->detachBehavior('captcha'); 62 | $this->assertEquals($formAttributes, $form->attributeNames()); 63 | $this->assertEquals($formAttributes, $form->attributeNames()); 64 | } 65 | 66 | /** 67 | * @dataProvider validDataProvider 68 | */ 69 | public function testValid($scenario, $attributes) 70 | { 71 | $form = new RecoveryForm($scenario); 72 | $form->userIdentityClass = 'UserIdentity'; 73 | $form->setAttributes($attributes); 74 | $this->assertTrue($form->validate(), 'Failed with following validation errors: '.print_r($form->getErrors(), true)); 75 | $this->assertEmpty($form->getErrors()); 76 | } 77 | 78 | /** 79 | * @dataProvider invalidDataProvider 80 | */ 81 | public function testInvalid($scenario, $attributes, $errors) 82 | { 83 | $form = new RecoveryForm($scenario); 84 | $form->userIdentityClass = 'UserIdentity'; 85 | $form->setAttributes($attributes); 86 | $this->assertFalse($form->validate()); 87 | $this->assertEquals($errors, $form->getErrors()); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /models/SearchForm.php: -------------------------------------------------------------------------------- 1 | _userIdentityClass; 33 | } 34 | 35 | public function setUserIdentityClass($value) 36 | { 37 | $this->_userIdentityClass = $value; 38 | } 39 | 40 | public function rules() 41 | { 42 | return array( 43 | array('id, username, email, firstName, lastName, createdOn, updatedOn, lastVisitOn, emailVerified, isActive, isDisabled, anyText', 'filter', 'filter' => 'trim'), 44 | array('id, username, email, firstName, lastName, createdOn, updatedOn, lastVisitOn, emailVerified, isActive, isDisabled, anyText', 'default'), 45 | array('id', 'numerical', 'integerOnly' => true, 'max' => 0x7FFFFFFF, 'min' => -0x8000000), // 32-bit integers 46 | array('createdOn, updatedOn, lastVisitOn', 'date', 'format' => array('yyyy-MM-dd', 'yyyy-MM-dd hh:mm', '?yyyy-MM-dd', '?yyyy-MM-dd hh:mm', '??yyyy-MM-dd', '??yyyy-MM-dd hh:mm')), 47 | array('emailVerified, isActive, isDisabled', 'boolean'), 48 | ); 49 | } 50 | 51 | /** 52 | * Declares attribute labels. 53 | */ 54 | public function attributeLabels() 55 | { 56 | return array( 57 | 'id' => Yii::t('UsrModule.manager', 'ID'), 58 | 'username' => Yii::t('UsrModule.manager', 'Username'), 59 | 'email' => Yii::t('UsrModule.manager', 'Email'), 60 | 'firstName' => Yii::t('UsrModule.manager', 'Firstname'), 61 | 'lastName' => Yii::t('UsrModule.manager', 'Lastname'), 62 | 'createdOn' => Yii::t('UsrModule.manager', 'Created On'), 63 | 'updatedOn' => Yii::t('UsrModule.manager', 'Updated On'), 64 | 'lastVisitOn' => Yii::t('UsrModule.manager', 'Last Visit On'), 65 | 'emailVerified' => Yii::t('UsrModule.manager', 'Email Verified'), 66 | 'isActive' => Yii::t('UsrModule.manager', 'Is Active'), 67 | 'isDisabled' => Yii::t('UsrModule.manager', 'Is Disabled'), 68 | 'anyText' => Yii::t('UsrModule.manager', 'Search'), 69 | ); 70 | } 71 | 72 | public function getIdentity($id = null) 73 | { 74 | if ($this->_identity === null) { 75 | $userIdentityClass = $this->userIdentityClass; 76 | $this->_identity = $userIdentityClass::find(array('id' => $id !== null ? $id : Yii::app()->user->getId())); 77 | if ($this->_identity !== null && !($this->_identity instanceof IManagedIdentity)) { 78 | throw new CException(Yii::t('UsrModule.usr', 'The {class} class must implement the {interface} interface.', array('{class}' => get_class($this->_identity), '{interface}' => 'IManagedIdentity'))); 79 | } 80 | } 81 | 82 | return $this->_identity; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /tests/unit/ProfileFormTest.php: -------------------------------------------------------------------------------- 1 | 'User', 12 | ); 13 | 14 | public static function validDataProvider() 15 | { 16 | return array( 17 | array( 18 | 'scenario' => '', 19 | 'attributes' => array( 20 | 'username' => 'trin', 21 | 'email' => 'trinity@matrix.com', 22 | 'firstName' => 'Trinity', 23 | 'lastName' => 'Latex', 24 | ), 25 | ), 26 | ); 27 | } 28 | 29 | public static function invalidDataProvider() 30 | { 31 | return array( 32 | array( 33 | 'scenario' => 'register', 34 | 'attributes' => array( 35 | 'username' => 'neo', 36 | 'email' => 'neo@matrix.com', 37 | 'firstName' => 'Neo', 38 | 'lastName' => 'Confused', 39 | ), 40 | 'errors ' => array( 41 | 'username' => array('neo has already been used by another user.'), 42 | ), 43 | ), 44 | ); 45 | } 46 | 47 | public static function allDataProvider() 48 | { 49 | return array_merge(self::validDataProvider(), self::invalidDataProvider()); 50 | } 51 | 52 | public function testWithBehavior() 53 | { 54 | $form = new ProfileForm(); 55 | $formAttributes = $form->attributeNames(); 56 | $formRules = $form->rules(); 57 | $formLabels = $form->attributeLabels(); 58 | $form->attachBehavior('captcha', array('class' => 'CaptchaFormBehavior')); 59 | $behaviorAttributes = $form->asa('captcha')->attributeNames(); 60 | $behaviorRules = $form->asa('captcha')->filterRules(); 61 | $behaviorLabels = $form->asa('captcha')->attributeLabels(); 62 | $this->assertEquals(array_merge($formAttributes, $behaviorAttributes), $form->attributeNames()); 63 | $this->assertEquals(array_merge($behaviorRules, $formRules), $form->rules()); 64 | $this->assertEquals(array_merge($formLabels, $behaviorLabels), $form->attributeLabels()); 65 | $form->detachBehavior('captcha'); 66 | $this->assertEquals($formAttributes, $form->attributeNames()); 67 | $this->assertEquals($formAttributes, $form->attributeNames()); 68 | } 69 | 70 | /** 71 | * @dataProvider validDataProvider 72 | */ 73 | public function testValid($scenario, $attributes) 74 | { 75 | $form = new ProfileForm($scenario); 76 | $form->userIdentityClass = 'UserIdentity'; 77 | $form->setAttributes($attributes); 78 | $this->assertTrue($form->validate(), 'Failed with following validation errors: '.print_r($form->getErrors(), true)); 79 | $this->assertEmpty($form->getErrors()); 80 | } 81 | 82 | /** 83 | * @dataProvider invalidDataProvider 84 | */ 85 | public function testInvalid($scenario, $attributes, $errors) 86 | { 87 | $form = new ProfileForm($scenario); 88 | $form->userIdentityClass = 'UserIdentity'; 89 | $form->setAttributes($attributes); 90 | $this->assertFalse($form->validate()); 91 | $this->assertEquals($errors, $form->getErrors()); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /components/OneTimePasswordAction.php: -------------------------------------------------------------------------------- 1 | user->isGuest) { 17 | $this->controller->redirect(array('login')); 18 | } 19 | $this->configuration = array_merge(array( 20 | 'authenticator' => null, 21 | 'mode' => null, 22 | 'required' => null, 23 | 'timeout' => null, 24 | ), $this->configuration); 25 | if ($this->configuration['required']) { 26 | $this->controller->redirect(array('profile')); 27 | } 28 | 29 | $model = new OneTimePasswordForm(); 30 | /** @var IUserIdentity */ 31 | $identity = $model->getIdentity(); 32 | /** 33 | * Disable OTP when a secret is set. 34 | */ 35 | if ($identity->getOneTimePasswordSecret() !== null) { 36 | $identity->setOneTimePasswordSecret(null); 37 | Yii::app()->request->cookies->remove(OneTimePasswordFormBehavior::OTP_COOKIE); 38 | $this->controller->redirect('profile'); 39 | 40 | return; 41 | } 42 | 43 | $model->setMode($this->configuration['mode'])->setAuthenticator($this->configuration['authenticator']); 44 | 45 | /** 46 | * When no secret has been set yet, generate a new secret and save it in session. 47 | * Do it if it hasn't been done yet. 48 | */ 49 | if (($secret = Yii::app()->session[OneTimePasswordFormBehavior::OTP_SECRET_PREFIX.'newSecret']) === null) { 50 | $secret = Yii::app()->session[OneTimePasswordFormBehavior::OTP_SECRET_PREFIX.'newSecret'] = $this->configuration['authenticator']->generateSecret(); 51 | 52 | $model->setSecret($secret); 53 | if ($this->configuration['mode'] === OneTimePasswordFormBehavior::OTP_COUNTER) { 54 | $this->controller->sendEmail($model, 'oneTimePassword'); 55 | } 56 | } 57 | $model->setSecret($secret); 58 | 59 | if (isset($_POST['OneTimePasswordForm'])) { 60 | $model->setAttributes($_POST['OneTimePasswordForm']); 61 | if ($model->validate()) { 62 | // save secret 63 | $identity->setOneTimePasswordSecret($secret); 64 | Yii::app()->session[OneTimePasswordFormBehavior::OTP_SECRET_PREFIX.'newSecret'] = null; 65 | // save current code as used 66 | $identity->setOneTimePassword($model->oneTimePassword, $this->configuration['mode'] === OneTimePasswordFormBehavior::OTP_TIME ? floor(time() / 30) : $model->getPreviousCounter() + 1); 67 | $this->controller->redirect('profile'); 68 | } 69 | } 70 | if (YII_DEBUG) { 71 | $model->oneTimePassword = $this->configuration['authenticator']->getCode($secret, $this->configuration['mode'] === OneTimePasswordFormBehavior::OTP_TIME ? null : $model->getPreviousCounter()); 72 | } 73 | 74 | if ($this->configuration['mode'] === OneTimePasswordFormBehavior::OTP_TIME) { 75 | $hostInfo = Yii::app()->request->hostInfo; 76 | $url = $model->getUrl($identity->username, parse_url($hostInfo, PHP_URL_HOST), $secret); 77 | } else { 78 | $url = ''; 79 | } 80 | 81 | $this->controller->render('generateOTPSecret', array( 82 | 'model' => $model, 83 | 'url' => $url, 84 | 'mode' => $this->configuration['mode'], 85 | )); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /extensions/Hybrid/Providers/Live.php: -------------------------------------------------------------------------------- 1 | 13 | * @version 0.2 14 | * @license BSD License 15 | */ 16 | 17 | /** 18 | * Hybrid_Providers_Live - Windows Live provider adapter based on OAuth2 protocol 19 | */ 20 | class Hybrid_Providers_Live extends Hybrid_Provider_Model_OAuth2 21 | { 22 | // default permissions 23 | public $scope = "wl.basic wl.emails wl.signin wl.share wl.birthday"; 24 | 25 | 26 | /** 27 | * IDp wrappers initializer 28 | */ 29 | function initialize() 30 | { 31 | parent::initialize(); 32 | 33 | // Provider api end-points 34 | $this->api->api_base_url = 'https://apis.live.net/v5.0/'; 35 | $this->api->authorize_url = 'https://login.live.com/oauth20_authorize.srf'; 36 | $this->api->token_url = 'https://login.live.com/oauth20_token.srf'; 37 | 38 | $this->api->curl_authenticate_method = "GET"; 39 | } 40 | 41 | /** 42 | * grab the user profile from the api client 43 | */ 44 | function getUserProfile() 45 | { 46 | $data = $this->api->get( "me" ); 47 | 48 | if ( ! isset( $data->id ) ){ 49 | throw new Exception( "User profile request failed! {$this->providerId} returned an invalide response.", 6 ); 50 | } 51 | 52 | $this->user->profile->identifier = (property_exists($data,'id'))?$data->id:""; 53 | $this->user->profile->firstName = (property_exists($data,'first_name'))?$data->first_name:""; 54 | $this->user->profile->lastName = (property_exists($data,'last_name'))?$data->last_name:""; 55 | $this->user->profile->displayName = (property_exists($data,'name'))?trim( $data->name ):""; 56 | $this->user->profile->gender = (property_exists($data,'gender'))?$data->gender:""; 57 | 58 | //wl.basic 59 | $this->user->profile->profileURL = (property_exists($data,'link'))?$data->link:""; 60 | 61 | //wl.emails 62 | $this->user->profile->email = (property_exists($data,'emails'))?$data->emails->account:""; 63 | $this->user->profile->emailVerified = (property_exists($data,'emails'))?$data->emails->account:""; 64 | 65 | //wl.birthday 66 | $this->user->profile->birthDay = (property_exists($data,'birth_day'))?$data->birth_day:""; 67 | $this->user->profile->birthMonth = (property_exists($data,'birth_month'))?$data->birth_month:""; 68 | $this->user->profile->birthYear = (property_exists($data,'birth_year'))?$data->birth_year:""; 69 | 70 | return $this->user->profile; 71 | } 72 | 73 | 74 | /** 75 | * load the current logged in user contacts list from the IDp api client 76 | */ 77 | 78 | /* Windows Live api does not support retrieval of email addresses (only hashes :/) */ 79 | function getUserContacts() 80 | { 81 | $response = $this->api->get( 'me/contacts' ); 82 | 83 | if ( $this->api->http_code != 200 ) 84 | { 85 | throw new Exception( 'User contacts request failed! ' . $this->providerId . ' returned an error: ' . $this->errorMessageByStatus( $this->api->http_code ) ); 86 | } 87 | 88 | if ( ! $response->data && ( $response->error != 0 ) ) 89 | { 90 | return array(); 91 | } 92 | 93 | $contacts = array(); 94 | 95 | foreach( $response->data as $item ) { 96 | $uc = new Hybrid_User_Contact(); 97 | 98 | $uc->identifier = (property_exists($item,'id'))?$item->id:""; 99 | $uc->displayName = (property_exists($item,'name'))?$item->name:""; 100 | 101 | $contacts[] = $uc; 102 | } 103 | 104 | return $contacts; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /tests/unit/LoginFormTest.php: -------------------------------------------------------------------------------- 1 | 'User', 13 | ); 14 | 15 | public static function validDataProvider() 16 | { 17 | return array( 18 | array( 19 | 'scenario' => '', 20 | 'attributes' => array( 21 | 'username' => 'neo', 22 | 'password' => 'Test1233', 23 | ), 24 | ), 25 | ); 26 | } 27 | 28 | public static function invalidDataProvider() 29 | { 30 | return array( 31 | array( 32 | 'scenario' => '', 33 | 'attributes' => array( 34 | 'username' => '', 35 | 'password' => '', 36 | ), 37 | 'errors ' => array( 38 | 'username' => array('Username cannot be blank.'), 39 | 'password' => array('Password cannot be blank.'), 40 | ), 41 | ), 42 | array( 43 | 'scenario' => '', 44 | 'attributes' => array( 45 | 'username' => 'neo', 46 | 'password' => 'xx', 47 | ), 48 | 'errors' => array( 49 | 'password' => array('Invalid username or password.'), 50 | ), 51 | ), 52 | ); 53 | } 54 | 55 | public static function allDataProvider() 56 | { 57 | return array_merge(self::validDataProvider(), self::invalidDataProvider()); 58 | } 59 | 60 | public function testWithBehavior() 61 | { 62 | $form = new LoginForm(); 63 | $formAttributes = $form->attributeNames(); 64 | $formRules = $form->rules(); 65 | $formLabels = $form->attributeLabels(); 66 | $form->attachBehavior('captcha', array('class' => 'CaptchaFormBehavior')); 67 | $behaviorAttributes = $form->asa('captcha')->attributeNames(); 68 | $behaviorRules = $form->asa('captcha')->filterRules(); 69 | $behaviorLabels = $form->asa('captcha')->attributeLabels(); 70 | $this->assertEquals(array_merge($formAttributes, $behaviorAttributes), $form->attributeNames()); 71 | $this->assertEquals(array_merge($formRules, $behaviorRules), $form->rules()); 72 | $this->assertEquals(array_merge($formLabels, $behaviorLabels), $form->attributeLabels()); 73 | $form->detachBehavior('captcha'); 74 | $this->assertEquals($formAttributes, $form->attributeNames()); 75 | $this->assertEquals($formAttributes, $form->attributeNames()); 76 | } 77 | 78 | /** 79 | * @dataProvider validDataProvider 80 | */ 81 | public function testValid($scenario, $attributes) 82 | { 83 | $form = new LoginForm($scenario); 84 | $form->userIdentityClass = 'UserIdentity'; 85 | $form->setAttributes($attributes); 86 | $this->assertTrue($form->validate(), 'Failed with following validation errors: '.print_r($form->getErrors(), true)); 87 | $this->assertEmpty($form->getErrors()); 88 | } 89 | 90 | /** 91 | * @dataProvider invalidDataProvider 92 | */ 93 | public function testInvalid($scenario, $attributes, $errors) 94 | { 95 | $form = new LoginForm($scenario); 96 | $form->userIdentityClass = 'UserIdentity'; 97 | $form->setAttributes($attributes); 98 | $this->assertFalse($form->validate()); 99 | $this->assertEquals($errors, $form->getErrors()); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /models/ExampleUserLoginAttempt.php: -------------------------------------------------------------------------------- 1 | array(self::BELONGS_TO, 'User', 'user_id'), 45 | ); 46 | } 47 | 48 | /** 49 | * @inheritdoc 50 | */ 51 | public function attributeLabels() 52 | { 53 | return array( 54 | 'id' => Yii::t('models', 'ID'), 55 | 'username' => Yii::t('models', 'Username'), 56 | 'user_id' => Yii::t('models', 'User'), 57 | 'performed_on' => Yii::t('models', 'Performed On'), 58 | 'is_successful' => Yii::t('models', 'Is Successful'), 59 | 'session_id' => Yii::t('models', 'Session ID'), 60 | 'ipv4' => Yii::t('models', 'IPv4'), 61 | 'user_agent' => Yii::t('models', 'User Agent'), 62 | ); 63 | } 64 | 65 | /** 66 | * @param string $className active record class name. 67 | * @return UserLoginAttempt the static model class 68 | */ 69 | public static function model($className = __CLASS__) 70 | { 71 | return parent::model($className); 72 | } 73 | 74 | protected function beforeSave() 75 | { 76 | if ($this->isNewRecord) { 77 | /** @var CHttpRequest */ 78 | $request = Yii::app()->request; 79 | $this->performed_on = date('Y-m-d H:i:s'); 80 | $this->session_id = Yii::app()->session->sessionID; 81 | $this->ipv4 = ip2long($request->userHostAddress); 82 | $this->user_agent = $request->userAgent; 83 | if ($this->ipv4 > 0x7FFFFFFF) { 84 | $this->ipv4 -= (0xFFFFFFFF + 1); 85 | } 86 | } 87 | 88 | return parent::beforeSave(); 89 | } 90 | 91 | /** 92 | * Checks if there are not too many login attempts using specified username in the specified number of seconds until now. 93 | * @param string $username 94 | * @param integer $count_limit number of login attempts 95 | * @param integer $time_limit number of seconds 96 | * @return boolean 97 | */ 98 | public static function hasTooManyFailedAttempts($username, $count_limit = 5, $time_limit = 1800) 99 | { 100 | $since = new DateTime(); 101 | $since->sub(new DateInterval("PT{$time_limit}S")); 102 | $subquery = UserLoginAttempt::model()->dbConnection->createCommand() 103 | ->select('is_successful') 104 | ->from(UserLoginAttempt::model()->tableName()) 105 | ->where('username = :username AND performed_on > :since') 106 | ->order('performed_on DESC') 107 | ->limit($count_limit)->getText(); 108 | 109 | return $count_limit <= (int) UserLoginAttempt::model()->dbConnection->createCommand() 110 | ->select('COUNT(NOT is_successful OR NULL)') 111 | ->from("({$subquery}) AS t") 112 | ->queryScalar(array(':username' => $username, ':since' => $since->format('Y-m-d H:i:s'))); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /extensions/GoogleAuthenticator.php/web/Users.php: -------------------------------------------------------------------------------- 1 | userFile = $file; 8 | 9 | $this->users = json_decode(file_get_contents($file),true); 10 | } 11 | function hasSession() { 12 | session_start(); 13 | if (isset($_SESSION['username'])) { 14 | return $_SESSION['username']; 15 | } 16 | return false; 17 | } 18 | 19 | 20 | function storeData(User $user) { 21 | $this->users[$user->getUsername()] = $user->getData(); 22 | file_put_contents($this->userFile,json_encode($this->users)); 23 | } 24 | 25 | function loadUser($name) { 26 | if (isset($this->users[$name])) { 27 | 28 | return new User($name,$this->users[$name]); 29 | } else { 30 | return false; 31 | } 32 | } 33 | 34 | 35 | 36 | } 37 | 38 | class User { 39 | 40 | function __construct($user,$data) { 41 | $this->data = $data; 42 | $this->user = $user; 43 | } 44 | 45 | function auth($pass) { 46 | if ($this->data['password'] === $pass) { 47 | return true; 48 | } 49 | 50 | return false; 51 | 52 | } 53 | 54 | function startSession() { 55 | 56 | $_SESSION['username'] = $this->user; 57 | } 58 | 59 | function doLogin() { 60 | session_regenerate_id(); 61 | $_SESSION['loggedin'] = true; 62 | $_SESSION['ua'] = $_SERVER['HTTP_USER_AGENT']; 63 | } 64 | 65 | function doOTP() { 66 | $_SESSION['OTP'] = true; 67 | } 68 | 69 | function isOTP() { 70 | if (isset($_SESSION['OTP']) && $_SESSION['OTP'] == true) { 71 | 72 | return true; 73 | } 74 | return false; 75 | 76 | } 77 | function isLoggedIn() { 78 | if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] == true && 79 | isset($_SESSION['ua']) && $_SESSION['ua'] == $_SERVER['HTTP_USER_AGENT'] 80 | ) { 81 | 82 | return $_SESSION['username']; 83 | } 84 | return false; 85 | 86 | } 87 | 88 | 89 | function getUsername() { 90 | return $this->user; 91 | } 92 | 93 | function getSecret() { 94 | if (isset($this->data['secret'])) { 95 | return $this->data['secret']; 96 | } 97 | return false; 98 | } 99 | 100 | function generateSecret() { 101 | $g = new GoogleAuthenticator(); 102 | $secret = $g->generateSecret(); 103 | $this->data['secret'] = $secret; 104 | return $secret; 105 | 106 | } 107 | 108 | function getData() { 109 | return $this->data; 110 | } 111 | 112 | function setOTPCookie() { 113 | $time = floor(time() / (3600 * 24) ); // get day number 114 | //about using the user agent: It's easy to fake it, but it increases the barrier for stealing and reusing cookies nevertheless 115 | // and it doesn't do any harm (except that it's invalid after a browser upgrade, but that may be even intented) 116 | $cookie = $time.":".hash_hmac("sha1",$this->getUsername().":".$time.":". $_SERVER['HTTP_USER_AGENT'],$this->getSecret()); 117 | setcookie ( "otp", $cookie, time() + (30 * 24 * 3600), null,null,null,true ); 118 | } 119 | 120 | function hasValidOTPCookie() { 121 | // 0 = tomorrow it is invalid 122 | $daysUntilInvalid = 0; 123 | $time = (string) floor((time() / (3600 * 24))) ; // get day number 124 | if (isset($_COOKIE['otp'])) { 125 | list( $otpday,$hash) = explode(":",$_COOKIE['otp']); 126 | 127 | if ( $otpday >= $time - $daysUntilInvalid && $hash == hash_hmac('sha1',$this->getUsername().":".$otpday .":". $_SERVER['HTTP_USER_AGENT'] , $this->getSecret()) 128 | ) { 129 | return true; 130 | } 131 | 132 | 133 | } 134 | return false; 135 | 136 | } 137 | 138 | } 139 | ?> 140 | -------------------------------------------------------------------------------- /extensions/GoogleAuthenticator.php/web/index.php: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | Google Authenticator in PHP demo 14 | 15 | 16 | hasSession()) { 24 | //load the user data from the json storage. 25 | $user = $users->loadUser($username); 26 | //if he clicked logout, destroy the session and redirect to the startscreen. 27 | if (isset($_GET['logout'])) { 28 | session_destroy(); 29 | header("Location: ./"); 30 | } 31 | // check if the user is logged in. 32 | if ($user->isLoggedIn()) { 33 | include("../tmpl/loggedin.php"); 34 | //show the QR code if whished so 35 | if (isset($_GET['showqr'])) { 36 | $secret = $user->getSecret(); 37 | include("../tmpl/show-qr.php"); 38 | } 39 | } 40 | //if the user is in the OTP phase and submit the OTP. 41 | else if ($user->isOTP() && isset($_POST['otp'])) { 42 | $g = new GoogleAuthenticator(); 43 | // check if the submitted token is the right one and log in 44 | if ($g->checkCode($user->getSecret(),$_POST['otp'])) { 45 | // do log-in the user 46 | $user->doLogin(); 47 | //if the user clicked the "remember the token" checkbox, set the cookie 48 | if (isset($_POST['remember']) && $_POST['remember']) { 49 | $user->setOTPCookie(); 50 | } 51 | include("../tmpl/loggedin.php"); 52 | } 53 | //if the OTP is wrong, destroy the session and tell the user to try again 54 | else { 55 | session_destroy(); 56 | include("../tmpl/login-error.php"); 57 | } 58 | 59 | } 60 | // if the user is neither logged in nor in the OTP phase, show the login form 61 | else { 62 | session_destroy(); 63 | include("../tmpl/login.php"); 64 | } 65 | die(); 66 | } 67 | //if the username is set in _POST, then we assume the user filled in the login form. 68 | else if (isset($_POST['username'])) { 69 | // check if we can load the user (ie. the user exists in our db) 70 | $user = $users->loadUser($_POST['username']); 71 | if ($user) { 72 | //try to authenticate the password and start the session if it's correct. 73 | if ($user->auth($_POST['password'])) { 74 | $user->startSession(); 75 | //check if the user has a valid OTP cookie, so we don't have to 76 | // ask for the current token and can directly log in 77 | if ($user->hasValidOTPCookie()) { 78 | include("../tmpl/loggedin.php"); 79 | $user->doLogin(); 80 | } 81 | // try to get the users' secret from the db, 82 | // if he doesn't have one, generate one, store it and show it. 83 | else if (!$user->getSecret()) { 84 | include("../tmpl/loggedin.php"); 85 | 86 | $secret = $user->generateSecret(); 87 | $users->storeData($user); 88 | $user->doLogin(); 89 | include("../tmpl/show-qr.php"); 90 | } 91 | // if the user neither has a valid OTP cookie nor it's the first login 92 | // ask for the OTP 93 | else { 94 | $user->doOTP(); 95 | include("../tmpl/ask-for-otp.php"); 96 | } 97 | 98 | 99 | die(); 100 | } 101 | } 102 | // if we're here, something went wrong, destroy the session and show a login error 103 | session_destroy(); 104 | 105 | include("../tmpl/login-error.php"); 106 | die(); 107 | } 108 | // if neither a session nor tried to submit the login credentials -> login screen 109 | include("../tmpl/login.php"); 110 | 111 | 112 | ?> 113 | 114 | --------------------------------------------------------------------------------