Just to add to what Phil has said, ever store passwords in clear text - it is a major security risk. There is some information on how to do it here:
Password Storage: How to do it.[
^]
And remember: if you have any European Union users then GDPR applies and that means you need to handle passwords as sensitive data and store them in a safe and secure manner. Text is neither of those and the fines can be .... um ... outstanding. In December 2018 a German company received a relatively low fine of €20,000 for just that.
And while he's right that you can't really put that code in it's own class, you are right that there is a mistake in your "whole app" design in that you have no real separation of concerns: it's a much better idea to adopt a "three layer" model, where the "presentation layer" (which deals with the user directly) is separate from the "business layer" (which deals with the rules for handling and manipulating data) and both are separate from the "data layer" (which deals with the basics of manipulating databases and other forms of storage). It's worth reading up on these:
Multitier architecture - Wikipedia[
^] will give you the basics.