Closed indicalabs closed 10 years ago
Which changes do you mean exactly?
Mongodb extension is expecting
I think if all this works by default, It would be great because out of the box "user" module is attractive and accelerate the development. I am not very good to fix the issue because I am a Java programmer and fall in love with Yii and learned PHP recently.
@klimov-paul can you look into it?
Paul, I think , there should be a way to deal with _id of mongodb, because having our own "id" returning as wrong id from ensureMongoId .
When we sign up, "status" field is not set with default value
How do you attempt to setup default value for the “status”? Please provide the code example.
For now I am able to resolve status field issue, but user module is not setting identity , because yii expects "id" where mongodb having "_id".
I am just expecting out of the box user module to work with mongodb by changing ActiveRecord
What is this “user module” you are mentioned?
Sorry I call user module which Yii framework has out of the box functionality for "signup", "login" ,"logout" and "rese-password".
In that case it should be enough to change method “User::getId()” to be following:
public function getId()
{
return $this->getPrimaryKey();
}
Thank Paul. That is working for me now. Currently "status" and "role" values are setting by the schema in the "user" table, that makes the new user Active by default. If we make change to the code to set these two fields with default values as part of core Yii framework, yii2-mongo will work for everyone without touching framework code.
Is it about advanced app template?
Yes
@samdark, perhaps it is better you'll handle this.
OK. Will do when I'll be back home (mid-January).
samdark, Just to be clear here,
$this->assign(Yii::$app->user->identity->id, Yii::$app->user->identity->role);
So that this Active user can be validated in custom rbac.php as soon as he Signed up@Venu85 please check if it's better now. And thanks for your report.
@samdark Login is successful now, the mongodb database has the below record after signup
{
"_id" : ObjectId("52c158e721182fb801d63af6"),
"username" : "22",
"email" : "xxxx@yahoo.com",
"create_time" : 1388402919,
"update_time" : 1388402919,
"password_hash" : "$2y$13$0KFR9.oDPVU.t.t21IoZkOA1l/97HAkkCKpciLSEJVpYE1Tr22PdO",
"auth_key" : "3IJfPVjzM404Heyv8-JTJ0Zy26FGOckm"
}
But the problem is, Since there is no status and role set,
Invalid Parameter – yii\base\InvalidParamException
Unknown authorization item ''.
at /Sites/advanced/vendor/yiisoft/yii2/yii/rbac/PhpManager.php
*/
public function assign($userId, $itemName, $bizRule = null, $data = null)
{
if (!isset($this->_items[$itemName])) {
throw new InvalidParamException("Unknown authorization item '$itemName'.");
Forgot to update scenarios
. Should be OK now.
I have started working with mongodb extension and able to work smoothly. But the default functionality like maintaining users , login, logout... needs changes in out of the box code. Is it possible to smoothly work with mongodb with defaults users functionality without many changes? Do we really need lot many changes to work with mongodb extension? Can we expect gii works with mongodb in future?
Thanks in advance