refactored authentication middleware
store token
check and send token