Added ability to generate authentication tokens by porting in some older Devise code