Build an authentication for another app with different users role

Hello i am very new to mongodb realm & atlas. I wonder if i can user mongodb to make like authentication function in http endpoints. I want to build authentication for my app where the users can register and login. I also want to have 2 different group of users like admin and user. Anyone can help me how build or write this kind of function?