{"id":23440899,"url":"https://github.com/tedconf/ember-ted-session","last_synced_at":"2025-04-09T20:37:39.357Z","repository":{"id":138188945,"uuid":"50538774","full_name":"tedconf/ember-ted-session","owner":"tedconf","description":"Easy user session management for your TED application","archived":false,"fork":false,"pushed_at":"2022-02-01T16:22:09.000Z","size":22,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":24,"default_branch":"master","last_synced_at":"2025-02-15T12:47:54.770Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tedconf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-01-27T21:23:42.000Z","updated_at":"2022-02-01T16:22:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"2a988be3-234c-491e-8e44-5289cc46100f","html_url":"https://github.com/tedconf/ember-ted-session","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tedconf%2Fember-ted-session","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tedconf%2Fember-ted-session/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tedconf%2Fember-ted-session/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tedconf%2Fember-ted-session/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tedconf","download_url":"https://codeload.github.com/tedconf/ember-ted-session/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248108892,"owners_count":21049220,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-23T16:20:24.499Z","updated_at":"2025-04-09T20:37:39.328Z","avatar_url":"https://github.com/tedconf.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deprecation Notice\n\nTED has shifted to React and will no longer maintain this application/library. If you wish to continue using this application/library, please create a pull request and repo ownership can be transferred. This repository will be archived at the end of 2022.\n\n# Ember-ted-session\n\nThis addon allows your Ember app to quickly pull in session based data,\nlike current user, from your TED backend.\n\n## Requirements\n\n* JSONAPI\n* Your application must have a `User` model.\n* If using authorization, your `User` model must have an `isAuthorized` property\n\n## Install\n\n`ember install ember-ted-session`\n\n## Usage\n\n### Current user\n\nAs soon as your application boots up you'll probably want to fetch the\ncurrent user. The `ted-session` service has a `#fetch` method for that.\n\n```javascript\n// application/route.js\n\nexport default Ember.Route.extend({\n  tedSession: Ember.inject.service(),\n\n  beforeModel() {\n    this.get('tedSession').fetch();\n  }\n});\n```\n\nNow any component can access the current user by just injecting the\nservice.\n\n```javascript\n// my-widget/component.js\n\nexport default Ember.Component.exnted({\n  tedSession: Ember.inject.service(),\n  currentUser: Ember.computed.readOnly('tedSession.currentUser')\n});\n```\n\n### Logging in\n\nIf you want to build a login form to let users login you can also use\nthe `ted-session` service to authenticate with the backend.\n\n```javascript\n// login/route.js\n\nexport default Ember.Route.extend({\n  tedSession: Ember.inject.service(),\n\n  actions: {\n    login(email, password) {\n      this.get('tedSession')\n        .login(email\n          , password)\n        .then(() =\u003e console.log('it worked'))\n        .catch(() =\u003e console.loa('nope'));\n    }\n  }\n});\n```\n\n### Generating an unauthorized route\n\nIf your app distinguishes between authorized and un-authorized users (eg. not all authenticated users are authorized), you will probably want to redirect unauthorized users to a page explaining what happened. This addon contains a custom generator for creating this automagically.\n\n##### Requirements: \n* a named `unauthorized` outlet in your application template: `{{outlet 'unauthorized'}}`\n\n##### Usage: \n\n* `ember generate unauthorized-route` will create a route named `unauthorized` and add it to your app's router.\n* `ember generate unauthorized-route aw-hells-no` will create the same but with your custom name (`aw-hells-no` in this case).\n\nThis generator will use your app's pod configuration and also accepts ember-cli's `--pod` flag.\n\n### Session service API\n\nAPI | Type | About | Returns | Example\n--- | --- | --- | --- | ---\n`fetch()` | `function` | Fetches the current user from the backend | `Promise` | `tedSessionService.fetch()`\n`terminate()` | `function` | Tells the backend to log the current user out | `Promise` | `tedSessionService.terminate()`\n`login(email, password)` | `function` | Logs in the user | `Promise` | `tedSessionService.login('rt@ted.com', 'password');`\n`currentUser` | `property` | Returns the current user | `User DS.Model` | `tedSession.get('currentUser')`\n`isLoggedIn` | `property` | Is there a current user | `Boolean` | `tedSession.get('isLoggedIn')`\n`isNotLoggedIn` | `property` | Is there no current user | `Boolean` | `tedSession.get('isNotLoggedIn')`\n`isAuthorized` | `property` | Returns `isAuthorized` property of the current user model, `false` if unavailable. | `Boolean` | `tedSession.get('isAuthorized')`\n\n## Details\n\n#### Payload\n\nThe get expects a JSON API document.\n\n```json\n// GET ted-sessions/current\n\n{\n  \"data\": {\n    \"id\": \"current\",\n    \"type\": \"ted-sessions\",\n    \"links\": {\n      \"self\": \"/ted-sessions/current\"\n    },\n    \"attributes\": {\n      \"csrf-token\": \"token\"\n    },\n    \"relationships\": {\n      \"user\": {\n        `isAuthorized`: true // optional \n        \"links\": {\n          \"self\": \"/ted-sessions/current/relationships/user\",\n          \"related\": \"/ted-sessions/current/user\"\n        }\n      }\n    }\n  }\n}\n```\n\nThe post however is formatted to match the JSON that a normal devise\nsession controller would expect.\n\n\n```json\n// POST ted-sessions/current\n\n\"user\": {\n  \"email\": \"email\",\n  \"password\": \"password\"\n}\n```\n\n#### CSRF token\n\nIf your response payload includes an attribute called `csrf-token` then\nit will be used as the `X-CSRF-TOKEN` in all future XHR requests.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftedconf%2Fember-ted-session","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftedconf%2Fember-ted-session","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftedconf%2Fember-ted-session/lists"}