[Solar-talk] Verifying Login Status
Raymond Kolbe
rkolbe at gmail.com
Wed Feb 6 18:02:37 CST 2008
In the config for auth it should be:
$config['Solar_Auth'] = array(
'adapter' => 'Solar_Auth_Adapter_Sql',
'table' => 'users',
''handle_col' => 'username',
'passwd_col' => 'password',
'uid_col' => 'id',
)
You shouldn't have to specify the 'process_login' key since this is pulled
from the locale settings (just add 'PROCESS_LOGIN => 'Login' in your locale
file (mine is en_US.php).
Hope that helps.
--Raymond Kolbe
On Feb 6, 2008 5:52 PM, Sean Montague <scene at themountainscene.com> wrote:
> Thanks Rodrigo,
>
> You say that it would be better to set the auth adapter configuration in
> the config file. Which makes sense to me, so now I'm trying to figure out
> the best way to do this. My modified Solar.config.php looks like this:
>
> $config['Solar_Sql'] = array(
> 'adapter' => 'Solar_Sql_Adapter_Mysql',
> 'host' => 'localhost',
> 'user' => 'root',
> 'pass' => 'mypass',
> 'name' => 'mydb'
> );
>
> $sql = Solar::factory('Solar_Sql', $config['Solar_Sql']);
> $config['Solar_Sql'] = array(
> 'sql' => $sql,
> 'adapter' => 'Solar_Auth_Adapter_Sql',
> 'table' => 'users',
> 'handle_col' => 'username',
> 'passwd_col' => 'password',
> 'uid_col' => 'id',
> 'process_login' => 'submit login'
> );
> ...
>
> My Login.php is looks like:
>
> $sql = solar::factory('solar_sql');
> $sql->_config['adapter'] = 'Solar_Auth_Adapter_Sql';
> $auth = Solar::factory('Solar_Auth', $sql->_config);
> $auth->start();
> ....
>
> In the config file, having "'adapter'=>'Solar_Auth_Adapter_Sql'" or
> "'adapter'=>'Solar_Sql_Adapter_Mysql'" makes no difference, they could just
> as easily be deleted. I need to set them in the Login.php script or the
> example I'm working with in Index.php, which looks like this:
>
> $sql = solar::factory('solar_sql');
> $sql->_config['adapter'] = 'Solar_Sql_Adapter_Mysql';
> $select = Solar::factory('Solar_Sql_Select', $sql->_config);
> $select->from('users',array('*'));
> ....
>
> All this works, and checking the authorization as you mentioned works too.
> Is setting $sql->_config['adapter'] the way I do a good idea? It seems like
> a hack for me to do it this way.
>
> Thanks!
> Sean
>
>
> Sean Montague wrote:
>
> On Feb 1, 2008 9:07 PM, Sean Montague wrote:
> >* I've worked through the tutorial on http://blog.phpdeveloper.org/?p=65*>* using Solar_Auth_Adapter_Sql, and I've set a session like:*>**>* $session = Solar::factory('Solar_Session',*>* array('class' => 'Vendor_App_Login')*>* );*>* $session->store['uid'] = $auth->uid;*>**>* Should I check the session in the bootstrap?*
> Not really, and, well, I prefer to keep the bootstrap cleaner as
> possible (just setting include ptah and making a Solar front
> controller call).
>
> You can initialize the auth proccess when initializing any app, with only this:
>
> $auth = Solar::factory('Solar_Auth');
> $auth->start();
> Solar_Registry::set('auth', $auth);
>
> Note that it would be better to set the auth adapter configuration in
> the config file, not in the factory call as in that tutorial. This way
> you can change the configuration more easily.
>
> Then to check if the use is logged in, you can call this anywhere:
> Solar_Registry::get('auth')->isValid(), like in:
>
> if (Solar_Registry::get('auth')->isValid()) {
> // user is logged in
> } else {
> // user is *not* logged in
> }
>
> Also you could use Solar_User, which wraps an auth object, plus role
> and access objects. But, for a simple authentication, just registering
> a start()'ed auth object as above would do the job.
>
> -- rodrigo
>
>
> _______________________________________________
> Solar-talk mailing list
> Solar-talk at lists.solarphp.com
> http://mailman-mail3.webfaction.com/listinfo/solar-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman-mail3.webfaction.com/pipermail/solar-talk/attachments/20080206/dde90d14/attachment.html
More information about the Solar-talk
mailing list