Refactor devise authenticate