Login with two seprate users in firebase










0















I created login page with firebase and i use firstore to store some info about the users like ID.
I created 2 types of users: Employer and Worker, When i register as employer, i store custom ID in firestore with 8 letters from the UID of the user and i add in 'e' at first of the string. I do the same thing when Worker register but i add 'w' in at first of the string.



Now when i try login as employer i want to go to certain activity and if i login as worker i want to go to certain activity.



I dont know how to do this,I'd be happy to get help.
enter image description here










share|improve this question






















  • Check this out. Is for Firebase realtime database but same principle apply to Cloud Firestore. So change your database structure a little bit to have only one collection because Firestore cannot allow you query the database across different collections.

    – Alex Mamo
    Nov 14 '18 at 11:22
















0















I created login page with firebase and i use firstore to store some info about the users like ID.
I created 2 types of users: Employer and Worker, When i register as employer, i store custom ID in firestore with 8 letters from the UID of the user and i add in 'e' at first of the string. I do the same thing when Worker register but i add 'w' in at first of the string.



Now when i try login as employer i want to go to certain activity and if i login as worker i want to go to certain activity.



I dont know how to do this,I'd be happy to get help.
enter image description here










share|improve this question






















  • Check this out. Is for Firebase realtime database but same principle apply to Cloud Firestore. So change your database structure a little bit to have only one collection because Firestore cannot allow you query the database across different collections.

    – Alex Mamo
    Nov 14 '18 at 11:22














0












0








0








I created login page with firebase and i use firstore to store some info about the users like ID.
I created 2 types of users: Employer and Worker, When i register as employer, i store custom ID in firestore with 8 letters from the UID of the user and i add in 'e' at first of the string. I do the same thing when Worker register but i add 'w' in at first of the string.



Now when i try login as employer i want to go to certain activity and if i login as worker i want to go to certain activity.



I dont know how to do this,I'd be happy to get help.
enter image description here










share|improve this question














I created login page with firebase and i use firstore to store some info about the users like ID.
I created 2 types of users: Employer and Worker, When i register as employer, i store custom ID in firestore with 8 letters from the UID of the user and i add in 'e' at first of the string. I do the same thing when Worker register but i add 'w' in at first of the string.



Now when i try login as employer i want to go to certain activity and if i login as worker i want to go to certain activity.



I dont know how to do this,I'd be happy to get help.
enter image description here







android firebase google-cloud-firestore






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 13 '18 at 21:56









matanmatan

287




287












  • Check this out. Is for Firebase realtime database but same principle apply to Cloud Firestore. So change your database structure a little bit to have only one collection because Firestore cannot allow you query the database across different collections.

    – Alex Mamo
    Nov 14 '18 at 11:22


















  • Check this out. Is for Firebase realtime database but same principle apply to Cloud Firestore. So change your database structure a little bit to have only one collection because Firestore cannot allow you query the database across different collections.

    – Alex Mamo
    Nov 14 '18 at 11:22

















Check this out. Is for Firebase realtime database but same principle apply to Cloud Firestore. So change your database structure a little bit to have only one collection because Firestore cannot allow you query the database across different collections.

– Alex Mamo
Nov 14 '18 at 11:22






Check this out. Is for Firebase realtime database but same principle apply to Cloud Firestore. So change your database structure a little bit to have only one collection because Firestore cannot allow you query the database across different collections.

– Alex Mamo
Nov 14 '18 at 11:22













1 Answer
1






active

oldest

votes


















0














The main launch activity can start another activity after login is complete. Edit whereever you want to do the transmission depending on the UID which in this case is either employer or worker. In the end you should be looking into something like this: *(As you provide no code block to help out,



 UID = getUID()//your method
Intent intent; //this is the intent you will start
if(UID == employee)//you can use first char to decide here

intent = new Intent(this, employer_activity.class);
startActivity(intent);//this will start that activity as employer

else if(UID == worker)

intent = new Intent(this, worker_activity.class);
startActivity(intent);//this will start that activity as worker






share|improve this answer























  • This code will not work, because if i do " UID = getUID()" I dont know if its UID of worker or employer.

    – matan
    Nov 14 '18 at 19:46











  • @matan you send a query to fetch that UID person's information table. and from that table get the ID so that the first character of the ID you get will tell you if it is E or W in the end. (or get ID_intent directly from UID to skip the second part)

    – koksalb
    Nov 15 '18 at 10:24











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53290122%2flogin-with-two-seprate-users-in-firebase%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














The main launch activity can start another activity after login is complete. Edit whereever you want to do the transmission depending on the UID which in this case is either employer or worker. In the end you should be looking into something like this: *(As you provide no code block to help out,



 UID = getUID()//your method
Intent intent; //this is the intent you will start
if(UID == employee)//you can use first char to decide here

intent = new Intent(this, employer_activity.class);
startActivity(intent);//this will start that activity as employer

else if(UID == worker)

intent = new Intent(this, worker_activity.class);
startActivity(intent);//this will start that activity as worker






share|improve this answer























  • This code will not work, because if i do " UID = getUID()" I dont know if its UID of worker or employer.

    – matan
    Nov 14 '18 at 19:46











  • @matan you send a query to fetch that UID person's information table. and from that table get the ID so that the first character of the ID you get will tell you if it is E or W in the end. (or get ID_intent directly from UID to skip the second part)

    – koksalb
    Nov 15 '18 at 10:24
















0














The main launch activity can start another activity after login is complete. Edit whereever you want to do the transmission depending on the UID which in this case is either employer or worker. In the end you should be looking into something like this: *(As you provide no code block to help out,



 UID = getUID()//your method
Intent intent; //this is the intent you will start
if(UID == employee)//you can use first char to decide here

intent = new Intent(this, employer_activity.class);
startActivity(intent);//this will start that activity as employer

else if(UID == worker)

intent = new Intent(this, worker_activity.class);
startActivity(intent);//this will start that activity as worker






share|improve this answer























  • This code will not work, because if i do " UID = getUID()" I dont know if its UID of worker or employer.

    – matan
    Nov 14 '18 at 19:46











  • @matan you send a query to fetch that UID person's information table. and from that table get the ID so that the first character of the ID you get will tell you if it is E or W in the end. (or get ID_intent directly from UID to skip the second part)

    – koksalb
    Nov 15 '18 at 10:24














0












0








0







The main launch activity can start another activity after login is complete. Edit whereever you want to do the transmission depending on the UID which in this case is either employer or worker. In the end you should be looking into something like this: *(As you provide no code block to help out,



 UID = getUID()//your method
Intent intent; //this is the intent you will start
if(UID == employee)//you can use first char to decide here

intent = new Intent(this, employer_activity.class);
startActivity(intent);//this will start that activity as employer

else if(UID == worker)

intent = new Intent(this, worker_activity.class);
startActivity(intent);//this will start that activity as worker






share|improve this answer













The main launch activity can start another activity after login is complete. Edit whereever you want to do the transmission depending on the UID which in this case is either employer or worker. In the end you should be looking into something like this: *(As you provide no code block to help out,



 UID = getUID()//your method
Intent intent; //this is the intent you will start
if(UID == employee)//you can use first char to decide here

intent = new Intent(this, employer_activity.class);
startActivity(intent);//this will start that activity as employer

else if(UID == worker)

intent = new Intent(this, worker_activity.class);
startActivity(intent);//this will start that activity as worker







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 13 '18 at 22:16









koksalbkoksalb

355613




355613












  • This code will not work, because if i do " UID = getUID()" I dont know if its UID of worker or employer.

    – matan
    Nov 14 '18 at 19:46











  • @matan you send a query to fetch that UID person's information table. and from that table get the ID so that the first character of the ID you get will tell you if it is E or W in the end. (or get ID_intent directly from UID to skip the second part)

    – koksalb
    Nov 15 '18 at 10:24


















  • This code will not work, because if i do " UID = getUID()" I dont know if its UID of worker or employer.

    – matan
    Nov 14 '18 at 19:46











  • @matan you send a query to fetch that UID person's information table. and from that table get the ID so that the first character of the ID you get will tell you if it is E or W in the end. (or get ID_intent directly from UID to skip the second part)

    – koksalb
    Nov 15 '18 at 10:24

















This code will not work, because if i do " UID = getUID()" I dont know if its UID of worker or employer.

– matan
Nov 14 '18 at 19:46





This code will not work, because if i do " UID = getUID()" I dont know if its UID of worker or employer.

– matan
Nov 14 '18 at 19:46













@matan you send a query to fetch that UID person's information table. and from that table get the ID so that the first character of the ID you get will tell you if it is E or W in the end. (or get ID_intent directly from UID to skip the second part)

– koksalb
Nov 15 '18 at 10:24






@matan you send a query to fetch that UID person's information table. and from that table get the ID so that the first character of the ID you get will tell you if it is E or W in the end. (or get ID_intent directly from UID to skip the second part)

– koksalb
Nov 15 '18 at 10:24


















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53290122%2flogin-with-two-seprate-users-in-firebase%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3