implemented login and authorization functions on model