I'm trying to setup hybrid auth on the Yii user management addon, the docs are here https://github.com/thyseus/yii-user-management/blob/master/user/docs/hybridauth.txt
according to this step
Take the modules/user/vendors/index.php, rename it to 'hybridauth.php' and place it
beside your application index.php bootstrap script. This will be your hybrid auth
entry script.
for this, there is NO index.php file in modules/user/vendors/index.php but there is one in modules/user/vendors/hybridauth/index.php which i renamed to hybridauth.php and put it in http://localhost/dev/ content of the hybridauth.php are
require_once( "protected/modules/user/vendors/hybridauth/Hybrid/Auth.php" );
require_once( "protected/modules/user/vendors/hybridauth/Hybrid/Endpoint.php" );
Hybrid_Endpoint::process();
now for this
Place the hybrid auth configuration file into your application
protected/config/hybridauth.php.
i took my modules/user/vendors/hybridauth/config.php and put it in protected/config/ and renamed config.php to hybridauth.php. the content looks like this
return
array(
"base_url" => Yii::app()->createAbsoluteUrl('/').'/hybridauth.php',
"providers" => array (
...........
"Google" => array (
"enabled" => true,
"keys" => array (
"id" => "ID",
"secret" => "SECRET",
),
),
"Facebook" => array (
"enabled" => true,
"keys" => array (
"id" => "ID",
"secret" => "SECRET",
),
"scope" => "email,user_birthday" // https://developers.facebook.com/docs/reference/login/
),
),
// if you want to enable logging, set 'debug_mode' to true then provide a writable file by the web server on "debug_file"
"debug_mode" => false,
"debug_file" => "",
);
problem is when i click say on the facebook icon on my login page, it shows my main page. (index.php)
here is the link it directs too
http://localhost/dev/index.php/hybridauth.php?hauth.start=Facebook&hauth.time=1388044835
when i remove the index.php from the url
http://localhost/dev/hybridauth.php?hauth.start=Facebook&hauth.time=1388044835
i get this error
You cannot access this page directly.
any idea what i'm doing wrong? Thanks
This sound like a routing problem in your configuration:
you might want to add a route for hybridauth.php and make sure it is only accessable by GET
for example :
'components'=>array(
......
'urlManager'=>array(
'showScriptName' => false,
'urlFormat'=>'path',
'rules'=>array(
'hybridauth'=>array('user/hybridauth/index', 'verb'=>'GET', 'urlSuffix'=>'.php'),
....
),
),
),
if anyone having the same problem, here is how i solved it:
by changing the base_url to point to the actual php file:
"base_url" => Yii::app()->getBaseUrl(true).'/hybridauth.php',
If you use YUM User Managment try to import
Yii::import('application.modules.profile.models.*');
on YumUserAuthController because profile cannot be found.
Related
I have following file structure
As default the url created for accessing the module content is for example
http://127.0.0.1/tmc/user/default/viewMessage
and for other controller it comes out to be
http://127.0.0.1/tmc/user/booking/index
The problem is I want to write a rule in my urlManager so that both controllers remain accessible AND i do not see default word in url as in first example.
However if i write following rules I am able to eliminate the default word but now other controllers in same module wont work. any help in this regard is appreciated
'<module:\w+>/<action:\w+>/<id:(.*?)>' => '<module>/default/<action>/<id>',
'<module:\w+>/<action:\w+>' => '<module>/default/<action>',
My current Url Manager is as follow
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false,
'rules' => array(
'/' => 'site/index',
'login' => 'site/login',
'user' => 'user/default/',
'<view:[a-zA-Z0-9-]+>/' => 'site/page',
),
),
Follow this Link for config settings
Refer this Link
//inside protected/modules/admin/AdminModule.php
class AdminModule extends CWebModule
{
//goes to TaskController instead of DefaultController
public $defaultController = 'Task';
...
Now your Yii application will routes to the “TaskController” if you request
index.php?r=admin
//same as requesting
index.php?r=admin/task
I am newbie for Yii. I have created my separate login page in my controller. Here my question is "When
When session expires it will ask for re-login. and it will transfer to site/login page.
Instead of site/login I want to redirect it to xyz/login page. Where I have to change this?
change in the main.php
array(
// ......
'components'=>array(
'user'=>array(
'loginUrl'=>array('xyz/login'),
),
),
)
in your config/main.php,
'urlManager' => array(
...
'rules' => array(
'xyz/login' => 'site/login', // Add this
...
I have the following main.php config
'clientScript'=>array(
'packages'=>array(
'jquery'=>array(
'baseUrl'=>'../www/js/jquery/',
'js'=>array('jquery.min.js'),
),
'jquery.ui'=>array(
'baseUrl'=>'../www/js/jquery/',
'js'=>array('jquery.ui.js'),
),
),
Both files are located in the same directory. The jquery script get loaded well but the jquery Ui does not.
Try This
public function registerAssets() {
Yii::app()->getClientScript()->registerCoreScript( 'jquery.ui' );
}
According to there site you can try followings
'clientScript' => array(
'scriptMap' => array(
'jquery.js' => '//ajax.googleapis.com/ajax/libs/jquery/1/jquery.js',
'jquery.min.js' => '//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js',
'jquery-ui.min.js' => '//ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js',
),
),
you can replace your jui location if u have already it in local
but they suggest to not do that, if you are curious please go to [yii site]: http://www.yiiframework.com/wiki/259/serve-jquery-and-jquery-ui-from-google-s-cdn/
I've added bootstrap Extension To my yii webapp and installed as described in setup Guide. All Folders in Extension Folder are rwrwrw but i get the error written above. What could be the reason? I've already dumped the path from yii::Import and that path was correct.
Thanks!
Edit With Code
This is my config:
Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/../extensions/bootstrap');
//Yii::setPathOfAlias('bootstrap', '/Users/gerritlober/Sites/yii/webapp/protected/extensions/bootstrap');
// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Carpool',
'theme' => 'bootstrap',
// preloading 'log' component
'preload'=>array('log'),
// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
),
'modules'=>array(
// uncomment the following to enable the Gii tool
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'xxx',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
'generatorPaths'=>array(
'bootstrap.gii',
),
),
),
// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
),
// uncomment the following to enable URLs in path-format
'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' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
),*/
// uncomment the following to use a MySQL database
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=carpool_dev',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'enableProfiling' => true,
),
'authManager'=>array(
'class'=>'CDbAuthManager',
'connectionID'=>'db',
),
'errorHandler'=>array(
// use 'site/error' action to display errors
'errorAction'=>'site/error',
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
// uncomment the following to show log messages on web pages
array(
'class'=>'CWebLogRoute',
'categories' => 'system.db.*,GLWeb.*,application.*'
),
),
),
'bootstrap'=>array(
'class'=>'bootstrap.components.Bootstrap',
),
),
// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params'=>array(
// this is used in contact page
'adminEmail'=>'webmaster#example.com',
),
);
My bootstrap extension is in ./protected/extensions/bootstrap
I was having the same problem. I granted full(777) permission to the folder.
Try it.
Update Component By :
ext.bootstrap.src.components.Bootstrap',
EG: If you are extracted under extension then follow above command:
Syntax: ext.path_to.Bootstrap
You have two options. One, in your config/main.php file, or equivalent, add the following line:
Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/../extensions/yii-bootstrap');
Where you need to replace yii-bootstrap with whatever your bootstrap folder is actually called.
Or two, you can simply refer to the that bootstrap folder correctly in the first place. If your bootstrap installation is installed in /extensions/yii-bootstrap as mine is, then use this alias to load components:
ext.yii-bootstrap.components.Bootstrap
In short, your problem is likely you aren't defining the path to your installation correctly. Use one of the two above solutions so remedy that problem.
I have installed 1.1.9 Yii framework.Then I made copy paste user module in my application folder and made changes to my main.php file.After all the configuration when I browsed the app and used user/login to login into my application, it showed error like this
Alias "user.UserModule" is invalid. Make sure it points to an existing PHP file.
I have checked my main.php files many times.But why it is showing error like this?any help,suggestions will be highly appriciable.
Here is my main.php file code.
<?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',
// preloading 'log' component
'preload'=>array('log'),
// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
#user module starts
'application.modules.user.models.*',
'application.modules.user.components.*',
#user module ends
),
'modules'=>array(
'user'=>array(
'returnUrl'=>array('/site/index'),
),
// uncomment the following to enable the Gii tool
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'XXXX',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
),
),
// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
'loginUrl'=>array('/user/login'),
),
// uncomment the following to enable URLs in path-format
/*
'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' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
//),
// uncomment the following to use a MySQL database
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=XXXX',
'emulatePrepare' => true,
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
'tablePrefix'=> 'tbl_',
),
'errorHandler'=>array(
// use 'site/error' action to display errors
'errorAction'=>'site/error',
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
// uncomment the following to show log messages on web pages
/*
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',
),
);
I got the error. The user module should be made copy paste under protected directory.Not any other directory.
Do you have a custom user module class? Based on 'application.modules.user.models.*', it seems like you do. In that case I think you'll need to set the class in the module declaration as well.