[Module] Account

Hey All,

Account, a brand new module form the Nord Software team is here.

If you are using the yii-user module you might want to upgrade to use the account module instead because it offers more security.

You can require it through Composer, download it from extensions or clone it from GitHub:

  • Account README

  • Account in extensions

  • Account on GitHub

Feel free to leave your thoughts below.

Hello;

First of all, big big thank you for this extension, I’m a fan of your awesome work :)

Second - a question: will it be difficult to convert it to bootstrap 2? I’m currently developing an application that uses Yiistrap with Bootstrap 2, I’m happy with this version of Bootstrap and don’t want to change it yet…

It’s actually really easy. Simply override the module views with your own that uses Bootstrap 2 (put them under either themes/[YOUR-THEME]/views/account or views/account - both should work).

I just released version 1.1.0 with some additional security features, check it out on the extension page.

Great, thank you very much for an answer :)


One more thing: since I’m still quite new to Yii, what would be the best approach to extend this module?

Right now my user table has a field “alias”, which is used as a param to generate an url username.mysite.com (used to display the “view” action). It also has many other fields, I wonder what’s the best way to merge these two models.

Easiest way to "merge" your user model is to add the required fields to that model and configure the module to use your model instead (you can set it in the $classMap property in the Module class). You also want to copy the password behavior to your user model in order to support proper password encryption (see Account model).

I will write a guide on how to extend the module soon. I’ll post here once I’m done.

wow…sound like wonderful extension, I follow install with composer but I still don’t get it… I’ve got files and folder: vendor, composer.json, composer.lock… so where folder of yii-account?

thanks bro

Composer places dependencies under vendor so the extension can be found under vendor/nordsoftware/yii-account after you have ran composer require.

I finished the "Extending" section in the README yesterday, it can be found here: https://github.com/nordsoftware/yii-account#extending

Please read it carefully if you plan on extending the extension with your own functionality.

Thank you very, very much! :) I’m reading it right away :)

Hi,

I’m trying to install the first extension for my first Yii project and am running into some trouble.

What am I doing wrong here?

Hi cris,

congratulations for the your work!!

I’m trying to configure the extension, but not getting to.

I did download the following packages:

yii-account https://github.com/nordsoftware/yii-account

Yiistrap http://github.com/crisu83/yiistrap

YiiPassword https://github.com/phpnode/yiipassword

RandomLib https://github.com/ircmaxell/RandomLib

SecurityLib https://github.com/ircmaxell/SecurityLib

put everything in the Extensions folder

and my main.php:


<?php


// uncomment the following to define a path alias

// Yii::setPathOfAlias('local','path/to/local-folder');


// This is the main Web application configuration. Any writable

// CWebApplication properties can be configured here.

return array(

	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',

	'name'=>'My Web Application',

        'aliases'=>array(

                'bootstrap'=>realpath(__DIR__ . '/../extensions/bootstrap'),

                '\nordsoftware\yii_account'=>__DIR__ . '/../extensions/yii-account/src',

                '\YiiPassword'=>__DIR__ . '/../extensions/yiipassword/src',

                '\RandomLib'=>__DIR__ . '/../extensions/randomlib/lib',

                '\SecureLib'=>__DIR__ . '/../extensions/securelib/lib',

        ),


	// preloading 'log' component

	'preload'=>array('log'),


	// autoloading model and component classes

	'import'=>array(

		'application.models.*',

		'application.components.*',

                'bootstrap.helpers.TbHtml',

	),


	'modules'=>array(

		'gii'=>array(

                        'generatorPaths'=>array('bootstrap.gii'),

			'class'=>'system.gii.GiiModule',

			'password'=>'*****',

			// If removed, Gii defaults to localhost only. Edit carefully to taste.

			'ipFilters'=>array('127.0.0.1','::1'),

		),

                'account'=>array(

                        'class'=>'\nordsoftware\yii_account\Module',

                ),

	),


	// application components

	'components'=>array(

                'cache'=>array('class'=>'system.caching.CFileCache'),

                'bootstrap'=>array(

                        'class'=>'bootstrap.components.TbApi',   

                ),

		'user'=>array(

                        'class'=>'\nordsoftware\yii_account\components\WebUser',

			// enable cookie-based authentication

			'allowAutoLogin'=>true,

		),

		'urlManager'=>array(

			'urlFormat'=>'path',

			'rules'=>array(

				'<controller:\w+>/<id:\d+>'=>'<controller>/view',

				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

			),

		),

		'db'=>array(

			'connectionString'=>'mysql:host=localhost;dbname=paintball',

			'emulatePrepare'=>true,

			'username'=>'root',

			'password'=>'',

			'charset'=>'utf8',

                        'enableParamLogging'=>true,                        

                        'tablePrefix'=>'',

		),

		'errorHandler'=>array(

			// use 'site/error' action to display errors

			'errorAction'=>'site/error',

		),

		'log'=>array(

			'class'=>'CLogRouter',

			'routes'=>array(

				array(

					'class'=>'CFileLogRoute',

					'levels'=>'error, warning',

				),

				array(

					'class'=>'CWebLogRoute',

				),

			),

		),

	),


	// application-level parameters that can be accessed

	// using Yii::app()->params['paramName']

	'params'=>array(

		// this is used in contact page

		'adminEmail'=>'webmaster@example.com',

	),

);

is giving the following error: "Alias "nordsoftware.yii_account.components" is invalid. Make sure it points to an existing directory or file."

can you help me?

Thanks,

Bruno Piaui

Same problem from Bruno Piaui and Patrick Bos Kessen.

Tried composer, no success.

Tried manually, no success.

Alias "nordsoftware.yii_account" is invalid. Make sure it points to an existing directory or file.

Chris,

I’m trying to get yii-account working on a DB other than MySQL (in my case SQL Server). I’ve been able to get everything working by making my own migration script and overriding all the models to add in a beforeSave() method to update the createdAt fields. However, there is one thing I can’t get around that I was wondering if you had any idea about how to configure.

The Helper::sqlNow() function is used in several places that is not easy to override and it is very MySQL centric. I’m currently using Composer for the dependency management and would prefer to not go to installing and modifying your extension, but I can’t seem to find anyway around it in SQL Server (I was even trying to configure a now() function but it can’t be called without “dbo.” in front of it so it didn’t work either).

The only way around it that I could come up with is to add a “nowSQL” property to the module and, from the Module.init(), set a static variable in the Helper for the SQL to use in the call. That allows the SQL to be specified in the configuration. This works, but it would require me to modify your code to put it in place (and I couldn’t find a way of subclassing all the other classes that require it without it).

Any help in getting around this would be appreciated.

Tracy

I have found the solution at http://www.yiilearning.com/solved-alias-nordsoftware-yii_account-is-invalid/