Created
October 7, 2012 23:01
-
-
Save pnegri/3849888 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| urrentProfile = -> | |
| id: null | |
| name: null | |
| email: null | |
| locale: 'en' | |
| active_account_id: null | |
| active_account_name: null | |
| logged_in: false | |
| logout: ( callback ) -> | |
| jQuery.ajax( | |
| type: "DELETE" | |
| url: window.logout_path + '.json' | |
| success: -> | |
| callback(true) if typeof(callback) == 'function' | |
| window.location.href = app_root_url if typeof(callback) != 'function' | |
| error: -> | |
| callback(false) if typeof(callback) == 'function' | |
| ) | |
| update_data: (data, callback) -> | |
| @logged_in = true if data.id | |
| unless data.id | |
| callback(false) if typeof(callback) == 'function' | |
| return false | |
| @id = data.ida | |
| @name = data.name if data.name | |
| @email = data.email | |
| @locale = data.locale | |
| @active_account_id = data.active_account_id | |
| @active_account_name = data.active_account_name | |
| debug 'Updated @CurrentProfile (' + api_profile_path + ')' | |
| callback(this) if typeof(callback) == 'function' | |
| refresh: (callback) -> | |
| that = @ | |
| jQuery.getJSON api_profile_path, (data) -> | |
| that.update_data data, callback | |
| @CurrentProfile = new CurrentProfile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment