diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml
new file mode 100644
index 0000000..de37104
--- /dev/null
+++ b/.idea/dataSources.xml
@@ -0,0 +1,12 @@
+
+
+
+
+ postgresql
+ true
+ org.postgresql.Driver
+ jdbc:postgresql://localhost:5432/mathy
+ $ProjectFileDir$
+
+
+
\ No newline at end of file
diff --git a/src/app/configs/app.config.ts b/src/app/configs/app.config.ts
index 57042be..992644c 100644
--- a/src/app/configs/app.config.ts
+++ b/src/app/configs/app.config.ts
@@ -1,5 +1,5 @@
import { env } from '@extollo/lib'
export default {
- name: env('APP_NAME', 'Extollo'),
+ name: env('APP_NAME', 'Mathy'),
}
diff --git a/src/app/configs/auth.config.ts b/src/app/configs/auth.config.ts
index a81b1b3..9e2e400 100644
--- a/src/app/configs/auth.config.ts
+++ b/src/app/configs/auth.config.ts
@@ -1,21 +1,8 @@
-import {AuthenticationConfig, CoreIDLoginProvider, OAuth2LoginProviderConfig, ORMUserRepository, env} from '@extollo/lib'
+import {AuthenticationConfig, ORMUserRepository} from '@extollo/lib'
const authConfig: AuthenticationConfig = {
storage: ORMUserRepository,
- providers: {
- coreid: {
- driver: CoreIDLoginProvider,
- config: {
- default: true,
- displayName: 'Starship CoreID',
- clientId: env('COREID_CLIENT_ID'),
- clientSecret: env('COREID_CLIENT_SECRET'),
- loginUrl: env('COREID_BASE', '') + '/auth/service/oauth2/authorize?client_id=%c&redirect_uri=%r',
- tokenUrl: env('COREID_BASE', '') + '/auth/service/oauth2/redeem',
- userUrl: env('COREID_BASE', '') + '/api/v1/auth/users/me',
- } as OAuth2LoginProviderConfig,
- }
- },
+ providers: {},
}
export default authConfig
diff --git a/src/app/configs/server.config.ts b/src/app/configs/server.config.ts
index 2bbdc2d..08a3824 100644
--- a/src/app/configs/server.config.ts
+++ b/src/app/configs/server.config.ts
@@ -6,9 +6,9 @@ import {
LocalFilesystemConfig,
RedisCache,
CacheQueue,
- BusConnectorConfig, QueueConfig, SyncQueue
+ BusConnectorConfig,
+ QueueConfig,
} from "@extollo/lib"
-import {LogRequest} from "../http/middlewares/LogRequest.middleware";
export default {
debug: env('DEBUG_MODE', false),
@@ -60,7 +60,7 @@ export default {
middleware: {
global: {
- pre: [LogRequest],
+ pre: [],
},
},
}
diff --git a/src/app/http/controllers/api/Login.controller.ts b/src/app/http/controllers/api/Login.controller.ts
new file mode 100644
index 0000000..363bb3b
--- /dev/null
+++ b/src/app/http/controllers/api/Login.controller.ts
@@ -0,0 +1,32 @@
+import {Controller, view, Inject, Injectable, SecurityContext, api} from '@extollo/lib'
+import {User} from '../../../models/User.model'
+
+/**
+ * Login Controller
+ * ------------------------------------
+ * API routes related to logging users into the application.
+ */
+@Injectable()
+export class Login extends Controller {
+ @Inject()
+ protected readonly security!: SecurityContext
+
+ public status() {
+ return api.one({
+ hasUser: this.security.hasUser(),
+ })
+ }
+
+ public user() {
+ const user = this.security.getUser()
+ if ( !user ) {
+ return api.error('There is no user authenticated.')
+ }
+
+ return api.one(user)
+ }
+
+ public async callbackFromAuth0() {
+ return api.error('Implement me!')
+ }
+}
diff --git a/src/app/http/controllers/main/Home.controller.ts b/src/app/http/controllers/main/Home.controller.ts
index 14275ba..63dc519 100644
--- a/src/app/http/controllers/main/Home.controller.ts
+++ b/src/app/http/controllers/main/Home.controller.ts
@@ -14,7 +14,7 @@ export class Home extends Controller {
const valid = new Promise(() => {})
- return view('@extollo:welcome', {
+ return view('welcome', {
app_visits: this.session.get('app_visits'),
locale: this.locale.helper(),
})
diff --git a/src/app/http/routes/app.routes.ts b/src/app/http/routes/app.routes.ts
index c7f578d..e76d1b2 100644
--- a/src/app/http/routes/app.routes.ts
+++ b/src/app/http/routes/app.routes.ts
@@ -1,13 +1,26 @@
-import {Route, SessionAuthMiddleware, AuthRequiredMiddleware} from '@extollo/lib'
+import {Route, SessionAuthMiddleware} from '@extollo/lib'
import {Home} from '../controllers/main/Home.controller'
+import {Login} from '../controllers/api/Login.controller'
Route.group('/', () => {
Route.get('/')
.calls(Home, home => home.welcome)
-})
-Route.group('', () => {
- Route.get('/dash')
- .pre(AuthRequiredMiddleware)
- .calls(Home, home => home.welcome)
+ Route.group('/api', () => {
+ Route.get('/')
+ .handledBy(() => ({
+ success: true,
+ }))
+
+ Route.group('/login', () => {
+ Route.get('/status')
+ .calls(Login, login => login.status)
+
+ Route.get('/user')
+ .calls(Login, login => login.user)
+
+ Route.post('/user')
+ .calls(Login, login => login.callbackFromAuth0)
+ })
+ })
}).pre(SessionAuthMiddleware)