Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Creating new user trough plugin

Creating new user trough plugin 1 year 1 month ago #99530

  • atlet
  • atlet's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 17
  • Karma: 0
Hi,

for login I created a plugin that checks if new user exist. If doesn't exist, it creates with this code
$oUser=new User;
$oUser->users_name=$sUser;
$oUser->password=hash('sha256', createPassword());
$oUser->full_name=$aUserProfile['full_name'];
$oUser->parent_id=1;
$oUser->lang='sl';
$oUser->email=$aUserProfile['email'];
$oUser->create_survey=TRUE;
 
if ($oUser->save())

But when it tries creating a new user, I get that error:
Property "User.create_survey" is not defined.

If I remove this line:
$oUser->create_survey=TRUE;

It's working fine. Is name of property create_survey different?

Regards Andraž
The administrator has disabled public write access.

Creating new user trough plugin 1 year 1 month ago #99566

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6451
  • Thank you received: 844
  • Karma: 249
In 2.05, we move "Permission" to plugin.

lime_permissions : entity: global :)
The administrator has disabled public write access.

Creating new user trough plugin 1 year 1 month ago #99571

  • atlet
  • atlet's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 17
  • Karma: 0
Aham. I was looking on plugin examples ...

github.com/LimeSurvey/LimeSurvey/blob/2....er/Authwebserver.php
The administrator has disabled public write access.

Creating new user trough plugin 1 year 1 month ago #99572

  • atlet
  • atlet's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 17
  • Karma: 0
Now I create with this code
$aPermissions['create_survey'] = $this->get('permission_create_survey', null, null, false);
                Permission::model()->setPermissions($oUser->uid, 0, 'global', $aPermissions);

But I get this error:
You are not allowed to set permisisons for this user
The administrator has disabled public write access.

Creating new user trough plugin 1 year 1 month ago #99581

  • atlet
  • atlet's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 17
  • Karma: 0
DenisChenu wrote:
In 2.05, we move "Permission" to plugin.

lime_permissions : entity: global :)

Do you have some example?
The administrator has disabled public write access.

Creating new user trough plugin 1 year 1 month ago #99589

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6451
  • Thank you received: 844
  • Karma: 249
The administrator has disabled public write access.

Creating new user trough plugin 1 year 1 month ago #99633

  • atlet
  • atlet's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 17
  • Karma: 0
The problem is, that I'm creating user trough login plugin - but I'm not logged in, so I don't have enough permissions to set user permissions... :(
The administrator has disabled public write access.

Creating new user trough plugin 1 year 1 month ago #99639

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6451
  • Thank you received: 844
  • Karma: 249
I don't understand : Loggued permission is used only in web access or with RemoteControl. If you make yourself a plugin : then you can "naot" control rights of user
The administrator has disabled public write access.

Creating new user trough plugin 1 year 1 month ago #99640

  • atlet
  • atlet's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 17
  • Karma: 0
So, the thing is, I created Authentication plugin with SimpleSAMLphp. If user doesn't exist in Limesurvey, I create it and assign permissions. It's working fine, but I would like using native methods when creating users. Now I'm writing directly to db, and this is not good solution...
The administrator has disabled public write access.

Creating new user trough plugin 1 year 1 month ago #99645

  • mdekker
  • mdekker's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 341
  • Thank you received: 68
  • Karma: 38
You just found the issues we still need to address. We intent to offer methods in the api for user creation / rights but had no use case for it. If you could file a bug report for the api methods you would like to see and assign it to me, I am more than happy to implement that. I want to have a look at your plugin too to see if the LS needs to be changed to make it more flexible. Open to discussion, please open a bug report so we can discuss there.

Thank you for the work done and interest in the project!
---
Menno Dekker
The administrator has disabled public write access.
The following user(s) said Thank You: atlet
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.266 seconds
Donation Image