mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-01-14 12:14:33 +01:00
@@ -66,7 +66,7 @@ export default class AuthController {
|
||||
|
||||
const twitterUser = await twitter.user()
|
||||
const user = await this.createUser(twitterUser)
|
||||
await auth.login(user)
|
||||
await auth.use('web').login(user)
|
||||
return response.status(200).send({
|
||||
user: user
|
||||
})
|
||||
@@ -95,7 +95,7 @@ export default class AuthController {
|
||||
|
||||
const githubUser = await github.user()
|
||||
const user = await this.createUser(githubUser)
|
||||
await auth.login(user)
|
||||
await auth.use('web').login(user)
|
||||
return response.status(200).send({
|
||||
user: user
|
||||
})
|
||||
@@ -124,7 +124,7 @@ export default class AuthController {
|
||||
|
||||
const googleUser = await google.user()
|
||||
const user = await this.createUser(googleUser)
|
||||
await auth.login(user)
|
||||
await auth.use('web').login(user)
|
||||
return response.status(200).send({
|
||||
user: user
|
||||
})
|
||||
|
||||
@@ -2,19 +2,24 @@ import {HttpContextContract} from "@ioc:Adonis/Core/HttpContext";
|
||||
import Redis from "@ioc:Adonis/Addons/Redis";
|
||||
import {UpdateGitHubReadme} from "App/Tasks/UpdateGithubReadme";
|
||||
|
||||
const STATES = [
|
||||
{sleeping: 'is_sleeping'},
|
||||
{listening: 'is_listening_music'},
|
||||
{developing: 'is_developing'},
|
||||
{learning: 'is_learning'}
|
||||
]
|
||||
|
||||
export default class StatesController {
|
||||
|
||||
public async get({response}: HttpContextContract) {
|
||||
const is_sleeping = await Redis.get('states:sleeping')
|
||||
const is_listening_music = await Redis.get('states:listening')
|
||||
const is_developing = await Redis.get('states:developing')
|
||||
const is_learning = await Redis.get('states:learning')
|
||||
const states = STATES.map(async state => {
|
||||
return this.getStatus(await Redis.get(`states:${state}`))
|
||||
})
|
||||
|
||||
return response.status(200).send({
|
||||
is_learning: this.getStatus(is_learning),
|
||||
is_sleeping: this.getStatus(is_sleeping),
|
||||
is_developing: this.getStatus(is_developing),
|
||||
is_listening_music: this.getStatus(is_listening_music)
|
||||
states: {
|
||||
...states
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -48,7 +53,7 @@ export default class StatesController {
|
||||
|
||||
await UpdateGitHubReadme()
|
||||
return response.status(200).send({
|
||||
message: 'State successfully updated !'
|
||||
message: 'State successfully updated!'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* file.
|
||||
*/
|
||||
|
||||
import { AuthConfig } from '@ioc:Adonis/Addons/Auth'
|
||||
import {AuthConfig} from '@ioc:Adonis/Addons/Auth'
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -19,6 +19,67 @@ import { AuthConfig } from '@ioc:Adonis/Addons/Auth'
|
||||
const authConfig: AuthConfig = {
|
||||
guard: 'api',
|
||||
guards: {
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Web Guard
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Web guard uses classic old school sessions for authenticating users.
|
||||
| If you are building a standard web application, it is recommended to
|
||||
| use web guard with session driver
|
||||
|
|
||||
*/
|
||||
web: {
|
||||
driver: 'session',
|
||||
|
||||
provider: {
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Name of the driver
|
||||
|
|
||||
*/
|
||||
driver: 'lucid',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Identifier key
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The identifier key is the unique key on the model. In most cases specifying
|
||||
| the primary key is the right choice.
|
||||
|
|
||||
*/
|
||||
identifierKey: 'id',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Uids
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Uids are used to search a user against one of the mentioned columns. During
|
||||
| login, the auth module will search the user mentioned value against one
|
||||
| of the mentioned columns to find their user record.
|
||||
|
|
||||
*/
|
||||
uids: ['email'],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Model
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The model to use for fetching or finding users. The model is imported
|
||||
| lazily since the config files are read way earlier in the lifecycle
|
||||
| of booting the app and the models may not be in a usable state at
|
||||
| that time.
|
||||
|
|
||||
*/
|
||||
model: () => import('App/Models/User'),
|
||||
},
|
||||
},
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| OAT Guard
|
||||
|
||||
@@ -55,6 +55,19 @@ declare module '@ioc:Adonis/Addons/Auth' {
|
||||
|
|
||||
*/
|
||||
interface GuardsList {
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Web Guard
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The web guard uses sessions for maintaining user login state. It uses
|
||||
| the `user` provider for fetching user details.
|
||||
|
|
||||
*/
|
||||
web: {
|
||||
implementation: SessionGuardContract<'user', 'web'>,
|
||||
config: SessionGuardConfig<'user'>,
|
||||
},
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| OAT Guard
|
||||
|
||||
Reference in New Issue
Block a user