Added code for flash messages and validation of passwords