Owncloud 6/7 with User Self Registration

Saturday, 23. November 2013

 

This Post is outdated!

Please use this Owncloud Application for owncloud 9 and higher!

thx
______________________________

On my school everyone is using some sort of cloud storage nowadays. there’s skydrive, googledrive, icloud and of course dropbox.  So i thought i’ll give them ONE cloud where they can share easily with each other and are in full control of their data.  There’s only one little problem. i don’t want to create 700-1000 accounts for students and teachers so it was clear that the users need to be able to register by themselves. it is enough work to delete all the accounts of dropouts and graduates anyway 🙂

since this feature is not implemented i decided to search the internet and i found a 4 months old ‘sort of functional’ implementation of the user “pellaeon” on github in a subtree (linked on mailing lists and forums).

i found out what is needed to make it work, fixed a lot of php bugs (introduced new ones ^^), CSS’ed it to fit in, ported it to owncloud 6 and added the option to filter “trusted” networks and only allow one registration per email address.

 

well there it is 🙂

registration (72KB zip)

(this file is containing the /registration/ folder – you can forget about the other files – they are for reference and information only)

 

loginemailcreate account

 

How To Install

1.) get OC 7

 https://owncloud.org/install/

 

2.) do not configure OC or create an admin user before finishing step 4 !

to install this on finalized installation you could always add the database table
‘pending_regist’ manually with an sqlite editor or phpmyadmin

3.) copy /registration/ folder into /core/ ( /core/registration/ )

4.) append table “pending_regist” to /db_structure.xml     ( right before the </database> closing tag )

<table>
<name>*dbprefix*pending_regist</name>
<declaration>
<field>
<name>email</name>
<type>text</type>
<default></default>
<notnull>true</notnull>
<length>64</length>
</field>
<field>
<name>token</name>
<type>text</type>
<default></default>
<notnull>false</notnull>
<length>256</length>
</field>
<field>
<name>requested</name>
<type>integer</type>
<default></default>
<notnull>true</notnull>
</field>
<index>
<name>pending_regist_pKey</name>
<primary>true</primary>
<field>
<name>requested</name>
<sorting>descending</sorting>
</field>
</index>
</declaration>
</table>

5.) append the following $classpath to /core/routes.php    ( last line )

OC::$CLASSPATH[‘OC_Core_Registration_Controller’] = ‘core/registration/controller.php’;
$this->create(‘core_registration_index’, ‘/register/’)
->get()
->action(‘OC_Core_Registration_Controller’, ‘index’);
$this->create(‘core_registration_send_email’, ‘/register/’)
->post()
->action(‘OC_Core_Registration_Controller’, ‘sendEmail’);
$this->create(‘core_registration_register_form’, ‘/register/verify/{token}’)
->get()
->action(‘OC_Core_Registration_Controller’, ‘registerForm’);
$this->create(‘core_registration_create_account’, ‘/register/verify/{token}’)
->post()
->action(‘OC_Core_Registration_Controller’, ‘createAccount’);

6.) append the following php code to /core/templates/login.php  ( last line )

require_once(‘core/registration/ip.php’);
if(fnmatch(“$iprange”, $_SERVER[‘REMOTE_ADDR’])){
$reglink = OC_Helper::linkToRoute(‘core_registration_index’);
echo “<p class=’info’> new to owncloud? <a href=’$reglink’ target=’_blank’> register! </a></p>”;
return;
}

 

7.) configure OC – create admin user (database with the new tables will be created)

8.) create a group for the new users called “selfregistered”

9.) logout

10.) give it a try

11.) change the value of $iprange in ‘core/registration/ip.php’ to your needs

wildcards allowed !
*    (everyone is allowed to register)
10.* ( registration is only available from local area network 10.xxx.xxx.xxx)
10.1.2.* (only subnet is allowed to register)

 

this is definitely an experiment. i’m no owncloud developer and i don’t have enough sparetime for doing it “right” (as owncloud APP for example)

the original creator stopped working on this 8 months ago so this is probably the best you can get right now..  if finally someone found the time to implement this as app – please let me know.. (email in the about.txt)

glhf

 

3 Responses to “Owncloud 6/7 with User Self Registration”



  1. tim Says:

    hey man, nice job you did here, nut one thing i cant seem to get.. what do i have to do whit “pending_regist”? where i have to add this? and when i add this in mysql, i need to have a column right..?

    Regards,
    Tim



  2. glen Says:

    Parse error: syntax error, unexpected ‘{‘ in /home/core/templates/login.php on line 72

    any idea?



  3. Jake Says:

    When clickling request link, it says there is an error and doesn’t send..