Luongmyno If you have more input into the school's IT, you might consider setting up an oauth2 service provider. Flarum has several oauth2 Single-Sign-On extensions, and several more made by the community, that would be an example for creating your own. Basically, the idea is that a student/teacher would be authenticated by the school, and then Flarum would get that authentication, and they would be registered/logged in.
If you don't have that kind of control, it's going to be much harder. A suggestion would be to use Davis' Invite Only extension, and generate per-user invites and send them to their emails. Depending on your school population, this would be an enormous task, but might be able to be automated by modifying the Invite extension for your own purposes.