Better in Back-end

Every time you have to develop some task on web apps, ask yourself: “I really need this here?”, there’s always two choices to implement functionalities I’m talking about Front-end and Back-end.
So if you have to manage some private data like usernames, passwords even dates or another type of information backend is your place, last week I was making a task about compares if there are no duplicates admin users while creating new ones, I completely missed the time when my mentor told me “don’t compare passwords in the front end that’s wrong”. but what’s wrong with that, its simple imagine you are building a house and you want to make it more secure you add security gate but you forgot to make walls, so anyone can go inside, just by surrounding the gate.
How that happens I was consuming and end point to ask all usernames in the back end and compare them in the front end before creating a new one was an awful idea.

I learned that now, and as an advice do everything that needs functionality on back end, only use front end to show the results of functionalities, for example if you have a list of food and you want to separate in fruits and vegetables to show in tow different tables just sent your target value as a parameter and wait for the answer in front end.

I know that Angular can do a large number o magical things but if take more minutes to make a function on your back end for the result you wanted do it doing go for the easy way in front end cause maybe now isn’t a big deal but in terms of security it worst and you don’t have to be an expert to know that nowadays security in your code it’s important.