Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 3 Support (Qt 5) › Authenticated user can create another account, Firebase

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #22239

    Edward

    Hey!

    My app requires all users to be authenticated with firebase – which is fine,

     

    Now I want ‘admins’ to be able to also add team members, by entering their details on a form and all the user needs to do is change their password on app download!

    I am able to write to my database area, but not register another user?

     

    For someone singing up themselves, I call;

    firebaseAuth.registerUser(email, password) //defined from strings on the form

     

    for my admins custom adding, I call;

    firebaseAuth.registerUser(AddEmail, AddPass)

     

    Is it not possible to add another user to firebase via this method?

    #22254

    Alex
    Felgo Team

    Hi Edward,

    interesting use case. It should definitely be possible to register new users this way. Things that would need to be tested, because I do no know them from the top of my head are:

    • If it works while logged in as another user, so maybe you have to call logout on the Firebase item first
    • If you are logged in to the new user after calling register, which means you’d have to log out after and log in with the admin user again (all that can be done without showing this to the user of course, just calling the methods)

    Cheers,
    Alex

    #22260

    Edward

    Hi Alex,

    This sounds like to would work – i’ll give it a go this evening, my only concern is that on calling logging out – is that when logging the admin user back in I would need to store the users password in app to run this all in the background, would this be insecure?

    #22419

    Edward

    Hi Guys,

    I’ve been having some real trouble with this issue, As mentioned before I am trying to achieve the following:

    1. My ‘admin’ inputs the ‘users’ firstname, surname, email (and other details)
    2. My function, firstly, writes inputted information into the appropriate ‘public’ area of the database, then logs out the current user (admin) (works fine)
    3. Registers the new user using firebaseAuth (which works and they appear as an authenticated user

    (THIS is where i’m having issues), what should happen is:

    1.  Whilst ‘logged in’ as the new user, I use my firebase.setUserValue, to write the above data, also to the user specific private branch
    2.  Log out, and log back in as the admin – all in the background.

    For some reason, even though I am logged out, and then authenticated as the new user, it is not working with the firebase.setUserValue(), although my console is returning ‘write completed’

     

    I have tried splitting this function into 2, by calling return; at the end of the initial registration, then storing the data/logging out/in separately to see if this was an issue with async, what could be causing this behaviour? as the function is nearly identical to my standard user registration one which works fine! Function below:

     

        function adminAddUser (AddFirstname, AddSurname, addSubGroup, AddEmail) {
            var i = getMySpecialYear(date)
            var addRegisterDetails = ({"firstname": AddFirstname, "surname": AddSurname, "email": AddEmail, "group": groupName, "subGroup": addSubGroup})
            firebaseDb.setValue("groups" + "/" + groupName + "/" + "users" + "/" + AddFirstname + " " + AddSurname + "/" + "details", addRegisterDetails)
            addPass = makeid(24)
    
            firebaseAuth.logoutUser();
            stack.popAllExceptFirstAndPush(homePage)
    
            return adminAddUserValues(AddEmail, addPass, AddFirstname, AddSurname, addSubGroup)
    }
    
        function adminAddUserValues(AddEmail, addPass, AddFirstname, AddSurname, addSubGroup) {
            firebaseAuth.registerUser(AddEmail, addPass)
            console.log(AddEmail + addPass+ AddFirstname + AddSurname + addSubGroup + groupName)
            var addUserDetails = ({"firstname": AddFirstname, "surname": AddSurname, "email": AddEmail})
    
            firebaseDb.setUserValue("subGroup", addSubGroup)
            firebaseDb.setUserValue("details", addUserDetails, 
            firebaseAuth.logoutUser()
            firebaseAuth.loginUser(email, userPass)
        }
    

     

    #22422

    Edward

    I have solved this issue, the end of my function needed to call firebaseAuth.registerUser,

     

    and within my auth – I needed to perform ‘setUserValue()’ not within the function, and this works fine – I am using a Boolean flag to identify if my user is registering as normal or as an ‘admin’ adding a user!

Viewing 5 posts - 1 through 5 (of 5 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded