0

I mean I can enter using the regulars sigin methos of the client SDK like signInWithEmailAndPassword method but I want and based on my email and password do regular operations as the admin-sdk do on the server, is that possible? use the admin-sdk functions on the client side with some sort authentication but at the same time not interfering with other users already signed in? I want to display different ui based on who I am but in the same application using vuejs components.

I am using the rules to restrict what a regular user can do but this is not the case of an admin user because if I login with a regular login method of the client sdk I am confined to the rules and if I signup as a regular user I can also do the same things as the admin which is not what I want, I want separated uis with separated actions.

Ahsath
  • 423
  • 1
  • 7
  • 19
  • Create an admin node, put the user Id's that you want to be admins, then for any admin action ( and whether to show a diffferent UI), check if the user Id is in the admin node? – Eric Guan Sep 24 '17 at 22:02
  • With the admin node you mean a node in the database like so: admin-node:{admin1: uid}? – Ahsath Sep 24 '17 at 22:43
  • Yeah but more like admin-node:{ uid: true}, since you just need a list of ID's. Since firebase is key-value, they recommend you just use "true" for the value. – Eric Guan Sep 24 '17 at 22:44
  • I don't understand what can I do with a true? – Ahsath Sep 24 '17 at 22:49
  • The true is meaningless, it can be literally any value, it's just one of Firebase's many oddities. All you need for the admin-node is an array of user Id's, assuming all admins are equal. Since Firebase doesn't support arrays, you need to use key-values. The key is the user Id. Firebase decided that "true" was the value you should use. https://stackoverflow.com/questions/40055764/setting-arrays-in-firebase-using-firebase-console – Eric Guan Sep 24 '17 at 22:51
  • So I can login to my admin dashboard (with a completely UI) from the app itself where users can register and login too? I just have from the server check the uid of the current signed user to see if he is an admin? – Ahsath Sep 24 '17 at 22:58
  • Yeah. If you want a single login point for both users and admins. – Eric Guan Sep 24 '17 at 23:00
  • So I signInWithEmailAndPassword method then inside the promise a need a ref to admin-node and check if the uid of the current signed user is set to true, if so display a different UI? But how do I get current uid with the signIn regular method on the client this does not return uid but error codes if something went wrong? – Ahsath Sep 24 '17 at 23:12

0 Answers0