How could I implement login with email address, not username ?

48 views
Skip to first unread message

Christophe Sertelet

unread,
Jul 20, 2016, 11:43:44 AM7/20/16
to PouchDB
Hi,

My users can connect to my mobile app by providing their username and password. I use pouchDB authentication plugin for that and it works fine : db.login(username, password [, options] [ callback]).

However, my usernames are fixed ids, that's too abstract for my users. 
I'd like to make it possible to connect to my app by providing email address instead of username (email addresses are saved in my _users database).
In other words, I'd like to log with a pouchdb function like that : db.loginWithEmail(emailAddress, password [, options] [ callback])

I don't want to use email addresses as usernames because they can (infrequently) change.

How could I do this with pouchDB ?


Thank's.

Christophe

Nolan Lawson

unread,
Aug 2, 2016, 11:22:13 PM8/2/16
to PouchDB
Hi Christophe,

The CouchDB _users database is a database like any other one. You can attach metadata to it and even create map/reduce views on it.

Cheers,
Nolan

Christophe Sertelet

unread,
Aug 16, 2016, 4:44:45 AM8/16/16
to PouchDB
Hi Nolan,

Thank's for your answer.

That's what I did but I wonder how to use pouchDb db.login function with such a configuration : db.login needs the username to operate but my users don't know their username, they only know their email address and password.
So, I'd like to call such a pouchDb function to let my users log in : db.loginWithEmail(emailAddress, password [, options] [ callback]).

How could I do this ? Could map/reduce views help me to do the job ?

My english is not fluent, so don't hesitate to tel me if I'm not being very clear ;-)

Cheers,

Christophe

Garren Smith

unread,
Aug 16, 2016, 4:47:38 AM8/16/16
to pou...@googlegroups.com
Hi Christophe,

You can use either map/reduce or pouchdb-find to look up the email address for that user.

Cheers
Garren

--
You received this message because you are subscribed to the Google Groups "PouchDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pouchdb+unsubscribe@googlegroups.com.
To post to this group, send email to pou...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pouchdb/532cdbfc-842a-4d5f-86d9-8246a8c11e3c%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Christophe Sertelet

unread,
Aug 22, 2016, 9:39:50 AM8/22/16
to PouchDB
Hi Garren,

Thanks for your answer.
But if I do that, these data (mail address and login) will be accessible by any malicious visitor, won't they ?

I'd like to allow my users to log with their mail address and password, without letting anybody knowing if a mail address is in my database or not. I don't see how to do this on the client side with PouchDb. Sorry if I misunderstand.

Cheers.

Christophe
Reply all
Reply to author
Forward
0 new messages