User permissions on firebase

0

Good morning, I'm having a question, I'm putting together an app where the person accesses it, logs in and password and then the home screen appears. if the person has not registered, she will register through the app itself, but my concern is the following. I want to create a rule where only a given user can create those users. eg the headteacher creates the user based on student data, eg RA (student record), but wanted to know how to do this rule, whether it is directly in the FIREBASE database in the web panel, or via app even in the androidstudio, and depending on what the choice would be, how would you do that?

    
asked by anonymous 24.01.2018 / 18:10

1 answer

1

You can block Activity registration for anyone who does not have permission to register the user. If it is only a user like you wrote can do so

  FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
  String userId = user.getUid();

  if(userId.equals("id permitido")){
      Intent intent = new Intent(this, CadastroActivity.class);
      startActivity(intent);
  } else {
      //É sempre importante avisar ao usuário o que está acontecendo
      Toast.makeText(this, "Apenas usuários autorizados podem cadastrar novos", Toast.LENGTH_SHORT).show();
  }
    
25.01.2018 / 19:20