L
L
Lev K2016-06-14 10:46:47
Yii
Lev K, 2016-06-14 10:46:47

Why can't I create a user in the yii2 basic admin panel?

Made an admin panel (created a separate controller). It already has a small amount of role management. But I can’t create a user in any way, I do it through a modal window, I send the data with ajax, as a result I can’t track exactly where the error is. How it's done?
And the code is like this:

$user = new User();
    	$user->status = User::STATUS_ACTIVE;
    	$user->username = Yii::$app->request->post('new_username');
    	$user->setPassword(Yii::$app->request->post('new_password'));
    	$user->email = '[email protected]';
    	$user->create_date = $user->update_date = date('Y-m-d H:m');
    	$user->generateAuthKey();
    	$user->save();

    	$role = new AuthAssignment();
    	$role->item_name = Yii::$app->request->post('new_role');
    	$role->user_id = $user->id;
    	$role->created_at = 123;
    	$role->save();

        Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
        return true;

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question