From e7dfed204e207933b0bf8cb39df0b3d53e0ee0e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Wed, 1 Apr 2026 18:35:01 +0400 Subject: [PATCH] Connect OSM account --- .env.development | 6 +- app/components/user-menu.gjs | 38 ++++- app/router.js | 3 + app/routes/oauth/osm-callback.js | 17 ++ app/services/osm-auth.js | 103 ++++++++++++ app/styles/app.css | 1 + package.json | 3 +- pnpm-lock.yaml | 8 + .../integration/components/user-menu-test.gjs | 102 ++++++++++++ tests/unit/routes/oauth/osm-callback-test.js | 47 ++++++ tests/unit/services/osm-auth-test.js | 156 ++++++++++++++++++ vite.config.mjs | 6 +- 12 files changed, 482 insertions(+), 8 deletions(-) create mode 100644 app/routes/oauth/osm-callback.js create mode 100644 app/services/osm-auth.js create mode 100644 tests/integration/components/user-menu-test.gjs create mode 100644 tests/unit/routes/oauth/osm-callback-test.js create mode 100644 tests/unit/services/osm-auth-test.js diff --git a/.env.development b/.env.development index f328914..d5ee466 100644 --- a/.env.development +++ b/.env.development @@ -1,8 +1,12 @@ # This file is committed to git and should not contain any secrets. -# +# # Vite recommends using .env.local or .env.[mode].local if you need to manage secrets # SEE: https://vite.dev/guide/env-and-mode.html#env-files for more information. # Default NODE_ENV with vite build --mode=test is production NODE_ENV=development + +# OpenStreetMap OAuth +VITE_OSM_CLIENT_ID=jIn8l5mT8FZOGYiIYXG1Yvj_2FZKB9TJ1edZwOJPsRU +VITE_OSM_OAUTH_URL=https://www.openstreetmap.org diff --git a/app/components/user-menu.gjs b/app/components/user-menu.gjs index db689ad..7abacd9 100644 --- a/app/components/user-menu.gjs +++ b/app/components/user-menu.gjs @@ -1,9 +1,13 @@ import Component from '@glimmer/component'; import { action } from '@ember/object'; +import { service } from '@ember/service'; import Icon from '#components/icon'; import { on } from '@ember/modifier'; export default class UserMenuComponent extends Component { + @service storage; + @service osmAuth; + @action connectRS() { this.args.onClose(); @@ -15,6 +19,17 @@ export default class UserMenuComponent extends Component { this.args.storage.disconnect(); } + @action + connectOsm() { + this.args.onClose(); + this.osmAuth.login(); + } + + @action + disconnectOsm() { + this.osmAuth.logout(); + } +