Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modernize addon: moved from webuniversum to appuniversum, converted to glimmer components #4

Merged
merged 13 commits into from Aug 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .editorconfig
Expand Up @@ -4,7 +4,6 @@

root = true


[*]
end_of_line = lf
charset = utf-8
Expand Down
2 changes: 2 additions & 0 deletions .eslintignore
Expand Up @@ -13,6 +13,8 @@
# misc
/coverage/
!.*
.*/
.eslintcache

# ember-try
/.node_modules.ember-try/
Expand Down
41 changes: 22 additions & 19 deletions .eslintrc.js
@@ -1,56 +1,59 @@
'use strict';

module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
legacyDecorators: true
}
legacyDecorators: true,
},
},
plugins: [
'ember'
],
plugins: ['ember'],
extends: [
'eslint:recommended',
'plugin:ember/recommended'
'plugin:ember/recommended',
'plugin:prettier/recommended',
],
env: {
browser: true
},
rules: {
'ember/no-jquery': 'error'
browser: true,
},
rules: {},
overrides: [
// node files
{
files: [
'.eslintrc.js',
'.prettierrc.js',
'.template-lintrc.js',
'ember-cli-build.js',
'index.js',
'testem.js',
'blueprints/*/index.js',
'config/**/*.js',
'tests/dummy/config/**/*.js'
'tests/dummy/config/**/*.js',
],
excludedFiles: [
'addon/**',
'addon-test-support/**',
'app/**',
'tests/dummy/app/**'
'tests/dummy/app/**',
],
parserOptions: {
sourceType: 'script'
sourceType: 'script',
},
env: {
browser: false,
node: true
node: true,
},
plugins: ['node'],
rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
// add your custom rules and overrides for node files here
})
}
]
extends: ['plugin:node/recommended'],
},
{
// Test files:
files: ['tests/**/*-test.{js,ts}'],
extends: ['plugin:qunit/recommended'],
},
],
};
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -12,6 +12,7 @@
/.env*
/.pnp*
/.sass-cache
/.eslintcache
/connect.lock
/coverage/
/libpeerconnection.log
Expand Down
6 changes: 5 additions & 1 deletion .npmignore
Expand Up @@ -8,12 +8,15 @@
# misc
/.bowerrc
/.editorconfig
/.ember-cli.js
/.ember-cli
/.env*
/.eslintcache
/.eslintignore
/.eslintrc.js
/.git/
/.gitignore
/.prettierignore
/.prettierrc.js
/.template-lintrc.js
/.travis.yml
/.watchmanconfig
Expand All @@ -23,6 +26,7 @@
/ember-cli-build.js
/testem.js
/tests/
/yarn-error.log
/yarn.lock
.gitkeep

Expand Down
21 changes: 21 additions & 0 deletions .prettierignore
@@ -0,0 +1,21 @@
# unconventional js
/blueprints/*/files/
/vendor/

# compiled output
/dist/
/tmp/

# dependencies
/bower_components/
/node_modules/

# misc
/coverage/
!.*
.eslintcache

# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/package.json.ember-try
5 changes: 5 additions & 0 deletions .prettierrc.js
@@ -0,0 +1,5 @@
'use strict';

module.exports = {
singleQuote: true,
};
2 changes: 1 addition & 1 deletion .template-lintrc.js
@@ -1,5 +1,5 @@
'use strict';

module.exports = {
extends: 'recommended'
extends: 'recommended',
};
28 changes: 17 additions & 11 deletions .travis.yml
Expand Up @@ -3,10 +3,9 @@ language: node_js
node_js:
# we recommend testing addons with the same minimum supported node version as Ember CLI
# so that your addon works for all apps
- "8"
- "10"

sudo: false
dist: trusty
dist: xenial

addons:
chrome: stable
Expand All @@ -27,29 +26,36 @@ branches:
- /^v\d+\.\d+\.\d+/

jobs:
fail_fast: true
fast_finish: true
allow_failures:
- env: EMBER_TRY_SCENARIO=ember-canary

include:
# runs linting and tests with current locked deps

- stage: "Tests"
name: "Tests"
script:
- npm run lint:hbs
- npm run lint:js
- npm test
- npm run lint
- npm run test:ember

- stage: "Additional Tests"
name: "Floating Dependencies"
install:
- npm install --no-package-lock
script:
- npm run test:ember

# we recommend new addons test the current and previous LTS
# as well as latest stable release (bonus points to beta/canary)
- stage: "Additional Tests"
env: EMBER_TRY_SCENARIO=ember-lts-3.4
- env: EMBER_TRY_SCENARIO=ember-lts-3.8
- env: EMBER_TRY_SCENARIO=ember-lts-3.20
- env: EMBER_TRY_SCENARIO=ember-lts-3.24
- env: EMBER_TRY_SCENARIO=ember-release
- env: EMBER_TRY_SCENARIO=ember-beta
- env: EMBER_TRY_SCENARIO=ember-canary
- env: EMBER_TRY_SCENARIO=ember-default-with-jquery
- env: EMBER_TRY_SCENARIO=ember-classic
- env: EMBER_TRY_SCENARIO=embroider-safe
- env: EMBER_TRY_SCENARIO=embroider-optimized

script:
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO
7 changes: 3 additions & 4 deletions CONTRIBUTING.md
Expand Up @@ -8,9 +8,8 @@

## Linting

* `npm run lint:hbs`
* `npm run lint:js`
* `npm run lint:js -- --fix`
* `npm run lint`
* `npm run lint:fix`

## Running tests

Expand All @@ -23,4 +22,4 @@
* `ember serve`
* Visit the dummy application at [http://localhost:4200](http://localhost:4200).

For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).
For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -7,9 +7,9 @@ Ember addon providing an Ember Simple Auth authenticator for ACM/IDM and a simpl
Compatibility
------------------------------------------------------------------------------

* Ember.js v3.4 or above
* Ember CLI v2.13 or above
* Node.js v8 or above
* Ember.js v3.20 or above
* Ember CLI v3.20 or above
* Node.js v10 or above


Installation
Expand Down
37 changes: 17 additions & 20 deletions addon/authenticators/torii.js
Expand Up @@ -5,23 +5,22 @@ import fetch, { Headers } from 'fetch';
const basePath = '/sessions';
const toriiProvider = 'acmidm-oauth2';


/**
* ACM/IDM OAuth2 authenticator
*/
export default ToriiAuthenticator.extend({
torii: service(),
*/
export default class AcmIdmOAuth2Authenticator extends ToriiAuthenticator {
@service torii;

async authenticate() {
const data = await this._super(...arguments); // get authorization code through Torii
const data = await super.authenticate(...arguments); // get authorization code through Torii
const result = await fetch(basePath, {
method: 'POST',
headers: new Headers({
'Content-Type': 'application/vnd.api+json'
'Content-Type': 'application/vnd.api+json',
}),
body: JSON.stringify({
authorizationCode: data.authorizationCode
})
authorizationCode: data.authorizationCode,
}),
});

if (result.ok) {
Expand All @@ -31,29 +30,27 @@ export default ToriiAuthenticator.extend({
} else {
throw result;
}
},
}

async invalidate() {
const result = await fetch(`${basePath}/current`, {
method: 'DELETE',
headers: new Headers({
'Content-Type': 'application/vnd.api+json'
})
'Content-Type': 'application/vnd.api+json',
}),
});

if (result.ok)
return result;
else
throw result;
},
if (result.ok) return result;
else throw result;
}

async restore() {
await this._super(...arguments);
await super.restore(...arguments);
const result = await fetch(`${basePath}/current`, {
method: 'GET',
headers: new Headers({
'Content-Type': 'application/vnd.api+json'
})
'Content-Type': 'application/vnd.api+json',
}),
});

if (result.ok) {
Expand All @@ -64,4 +61,4 @@ export default ToriiAuthenticator.extend({
throw result;
}
}
});
}
12 changes: 12 additions & 0 deletions addon/components/acmidm-login.hbs
@@ -0,0 +1,12 @@
<Acmidm::Login as |acmidm|>
<AuButton
@loading={{acmidm.isAuthenticating}}
@disabled={{acmidm.isAuthenticating}}
{{on "click" acmidm.login}}
>
Meld u aan
</AuButton>
{{#if acmidm.errorMessage}}
<AuAlert @alertIcon="alert-triangle" @alertTitle={{acmidm.errorMessage}} />
{{/if}}
</Acmidm::Login>
28 changes: 3 additions & 25 deletions addon/components/acmidm-login.js
@@ -1,26 +1,4 @@
import { warn } from '@ember/debug';
import Component from '@ember/component';
import layout from '../templates/components/acmidm-login';
import { inject as service } from '@ember/service';
import templateOnly from '@ember/component/template-only';

export default Component.extend({
layout,
session: service('session'),
actions: {
login() {
this.set('errorMessage', '');
this.set('isAuthenticating', true);
this.session.authenticate('authenticator:torii', 'acmidm-oauth2').catch((reason) => {
warn(reason.error || reason, { id: 'authentication.failure' });

if (reason.status == 403)
this.set('errorMessage', 'U heeft geen toegang tot deze applicatie.');
else
this.set('errorMessage', 'Fout bij het aanmelden. Gelieve opnieuw te proberen.');
})
.finally(() => {
this.set('isAuthenticating', false);
});
}
}
});
const AcmidmLoginComponent = templateOnly();
export default AcmidmLoginComponent;
7 changes: 7 additions & 0 deletions addon/components/acmidm-logout.hbs
@@ -0,0 +1,7 @@
<button ...attributes type="button" {{on "click" this.logout}}>
{{#if (has-block)}}
{{yield}}
{{else}}
Meld u af
{{/if}}
</button>