User management

161 views
Skip to first unread message

Joel Saltzman

unread,
May 19, 2014, 12:07:52 PM5/19/14
to mobile-c...@googlegroups.com
I'm looking to allow users to create their own accounts and have private access to only their content in the database. e.g. I don't want user A to sync any of user B's info. The easiest example I can think of is github users and repos. I understand that I should add to _users and create channels for each user.

Is there a way to do this through couchbase lite or do I have to create a separate script server side (like in php or something) to modify the _users info?

J. Chris Anderson

unread,
May 19, 2014, 1:25:36 PM5/19/14
to mobile-c...@googlegroups.com


On Monday, May 19, 2014 9:07:52 AM UTC-7, Joel Saltzman wrote:
I'm looking to allow users to create their own accounts and have private access to only their content in the database. e.g. I don't want user A to sync any of user B's info. The easiest example I can think of is github users and repos. I understand that I should add to _users and create channels for each user.

Is there a way to do this through couchbase lite or do I have to create a separate script server side (like in php or something) to modify the _users info?

The sync function API allows you to have documents which make those sort of changes dynamically. 

Here are the docs, we are working on more tutorials: http://docs.couchbase.com/sync-gateway/#sync-gateway-apis

Chris 

Joel Saltzman

unread,
Jun 14, 2014, 1:46:11 AM6/14/14
to mobile-c...@googlegroups.com
I went through the demo for the couchchat and I found that it requires a Persona login/signup and once verified the sync_gateway creates the _user. Is there a way to create a _user via the sync function or something similar? I was hoping to get around making a separate script server side to create users.

Rajagopal V

unread,
Jun 14, 2014, 8:25:22 AM6/14/14
to mobile-c...@googlegroups.com
If you look at the Admin REST API endpoints in http://docs.couchbase.com/sync-gateway/#admin-rest-api, you can see that there are calls to /$DB/_user/ (as POST) to create a user and /$DB/_user/$name as PUT to update the users. The parameters to the user are provided at http://docs.couchbase.com/sync-gateway/#authorizing-users under the "Accounts" section.  

Joel Saltzman

unread,
Jun 14, 2014, 9:51:32 AM6/14/14
to mobile-c...@googlegroups.com
Yes, but the admin port should not be exposed. I am looking to give users a way to create their own accounts without Persona or Facebook, exposing the admin port or making a separate script. I’m guessing It can’t be done...


-- 
You received this message because you are subscribed to a topic in the Google Groups "Couchbase Mobile" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mobile-couchbase/akDzslUzgaE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/4a767b53-c66a-4386-a23d-27c56b3b6533%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jens Alfke

unread,
Jun 14, 2014, 2:05:34 PM6/14/14
to mobile-c...@googlegroups.com

On Jun 14, 2014, at 6:51 AM, Joel Saltzman <saltzm...@gmail.com> wrote:

Yes, but the admin port should not be exposed. I am looking to give users a way to create their own accounts without Persona or Facebook, exposing the admin port or making a separate script. I’m guessing It can’t be done...

The Gateway doesn’t support self-registration of user accounts. That would be a good feature to add in a future release. I don’t think anyone’s requested it before, so you can file an issue on Github.

It would be easy to write a server-side script that does this — probably a few dozen lines of your favorite scripting language. You just need to accept a POST from the client, then turn around and PUT /db/username on the Gateway’s admin port. You’d probably then want to add features like letting the user change their password or delete their account. It shouldn’t take more than a day or two to put something like this together. If anyone does so and would like to contribute the script, I’d gratefully add it to the Gateway repository or wiki.

—Jens

Ragu Vijaykumar

unread,
Jun 17, 2014, 7:01:28 PM6/17/14
to mobile-c...@googlegroups.com
I've been wondering about whether to use Parse for the user management aspects, and have it fire cloud code to one's Couchbase server to open up a channel for the user. Has anyone tried this?

Ragu

Joel Saltzman

unread,
Jun 22, 2014, 12:38:28 AM6/22/14
to mobile-c...@googlegroups.com
Ok, I will put something together then. Thanks

--
You received this message because you are subscribed to a topic in the Google Groups "Couchbase Mobile" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mobile-couchbase/akDzslUzgaE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mobile-couchba...@googlegroups.com.

J. Chris Anderson

unread,
Jun 22, 2014, 3:57:54 PM6/22/14
to mobile-c...@googlegroups.com


On Saturday, June 21, 2014 9:38:28 PM UTC-7, Joel Saltzman wrote:
Ok, I will put something together then. Thanks

On Jun 14, 2014, at 11:05 AM, Jens Alfke <je...@couchbase.com> wrote:


On Jun 14, 2014, at 6:51 AM, Joel Saltzman <saltzm...@gmail.com> wrote:

Yes, but the admin port should not be exposed. I am looking to give users a way to create their own accounts without Persona or Facebook, exposing the admin port or making a separate script. I’m guessing It can’t be done...

The Gateway doesn’t support self-registration of user accounts. That would be a good feature to add in a future release. I don’t think anyone’s requested it before, so you can file an issue on Github.

It would be easy to write a server-side script that does this — probably a few dozen lines of your favorite scripting language. You just need to accept a POST from the client, then turn around and PUT /db/username on the Gateway’s admin port. You’d probably then want to add features like letting the user change their password or delete their account. It shouldn’t take more than a day or two to put something like this together. If anyone does so and would like to contribute the script, I’d gratefully add it to the Gateway repository or wiki.

There's an example that does this with the Linked In API for identity. It's pretty simple to implement in any language, this was in Node.js.
 

—Jens

--
You received this message because you are subscribed to a topic in the Google Groups "Couchbase Mobile" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mobile-couchbase/akDzslUzgaE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mobile-couchbase+unsubscribe@googlegroups.com.

Joel Saltzman

unread,
Jul 24, 2014, 12:22:05 PM7/24/14
to mobile-c...@googlegroups.com
I had to brush up on javascript and learn some jquery but here is what I put together. Please let me know what you think:

CouchbaseLover

unread,
Jul 24, 2014, 4:09:37 PM7/24/14
to mobile-c...@googlegroups.com
Impressive! 

Joel Saltzman

unread,
Jul 24, 2014, 4:16:08 PM7/24/14
to mobile-c...@googlegroups.com
Thanks. It could use some polishing for sure.
Reply all
Reply to author
Forward
0 new messages