fix date / hour selection on import
This commit is contained in:
@@ -17,7 +17,7 @@ v-col(cols=12)
|
|||||||
vc-date-picker(
|
vc-date-picker(
|
||||||
v-model='fromDate'
|
v-model='fromDate'
|
||||||
:is-range='type === "multidate"'
|
:is-range='type === "multidate"'
|
||||||
@input="date => change('date', fromDate)"
|
@input="date => change('date', date)"
|
||||||
:timezone='settings.instance_timezone'
|
:timezone='settings.instance_timezone'
|
||||||
:attributes='attributes'
|
:attributes='attributes'
|
||||||
:locale='$i18n.locale'
|
:locale='$i18n.locale'
|
||||||
@@ -106,21 +106,10 @@ export default {
|
|||||||
event: { type: Object, default: () => null }
|
event: { type: Object, default: () => null }
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
let fromDate
|
|
||||||
if (this.value.from) {
|
|
||||||
if (this.value.multidate) {
|
|
||||||
fromDate = ({ start: dayjs(this.value.from).toDate(), end: dayjs(this.value.due).toDate() })
|
|
||||||
} else {
|
|
||||||
fromDate = new Date(this.value.from)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
mdiClockTimeFourOutline, mdiClockTimeEightOutline, mdiClose,
|
mdiClockTimeFourOutline, mdiClockTimeEightOutline, mdiClose,
|
||||||
allowedMinutes: [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55],
|
allowedMinutes: [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55],
|
||||||
menuFromHour: false,
|
menuFromHour: false,
|
||||||
fromDate,
|
|
||||||
fromHour: this.value.from && dayjs.tz(this.value.from).format('HH:mm'),
|
|
||||||
dueHour: this.value.due && dayjs.tz(this.value.due).format('HH:mm'),
|
|
||||||
menuDueHour: false,
|
menuDueHour: false,
|
||||||
type: this.value.type || 'normal',
|
type: this.value.type || 'normal',
|
||||||
events: [],
|
events: [],
|
||||||
@@ -133,6 +122,26 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['settings']),
|
...mapState(['settings']),
|
||||||
|
fromDate: {
|
||||||
|
set: () => {},
|
||||||
|
get: function () {
|
||||||
|
if (this.value.from) {
|
||||||
|
if (this.value.multidate) {
|
||||||
|
return ({ start: dayjs(this.value.from).toDate(), end: dayjs(this.value.due).toDate() })
|
||||||
|
} else {
|
||||||
|
return new Date(this.value.from)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fromHour: {
|
||||||
|
set: () => {},
|
||||||
|
get () { return this.value.from && dayjs.tz(this.value.from).format('HH:mm') || '' }
|
||||||
|
},
|
||||||
|
dueHour: {
|
||||||
|
set: () => {},
|
||||||
|
get () { return this.value.due && dayjs.tz(this.value.due).format('HH:mm') || '' }
|
||||||
|
},
|
||||||
todayEvents() {
|
todayEvents() {
|
||||||
const start = dayjs.tz(this.value.from).startOf('day').unix()
|
const start = dayjs.tz(this.value.from).startOf('day').unix()
|
||||||
const end = dayjs.tz(this.value.from).endOf('day').unix()
|
const end = dayjs.tz(this.value.from).endOf('day').unix()
|
||||||
@@ -227,16 +236,12 @@ export default {
|
|||||||
} else if (what === 'recurrentType') {
|
} else if (what === 'recurrentType') {
|
||||||
this.$emit('input', { ...this.value, recurrent: { ...this.value.recurrent, type: value } })
|
this.$emit('input', { ...this.value, recurrent: { ...this.value.recurrent, type: value } })
|
||||||
} else if (what === 'fromHour') {
|
} else if (what === 'fromHour') {
|
||||||
// if (value) {
|
|
||||||
const [hour, minute] = value ? value.split(':') : [0, 0]
|
const [hour, minute] = value ? value.split(':') : [0, 0]
|
||||||
let from = dayjs.tz(this.value.from).hour(hour).minute(minute).second(0).toDate()
|
let from = dayjs.tz(this.value.from).hour(hour).minute(minute).second(0).toDate()
|
||||||
this.$emit('input', { ...this.value, from })
|
this.$emit('input', { ...this.value, from })
|
||||||
if (!value) {
|
if (!value) {
|
||||||
this.fromHour = null
|
this.fromHour = null
|
||||||
}
|
}
|
||||||
// } else {
|
|
||||||
// this.$emit('input', { ...this.value })
|
|
||||||
// }
|
|
||||||
} else if (what === 'dueHour') {
|
} else if (what === 'dueHour') {
|
||||||
if (value) {
|
if (value) {
|
||||||
const [hour, minute] = value.split(':')
|
const [hour, minute] = value.split(':')
|
||||||
|
|||||||
@@ -142,10 +142,10 @@
|
|||||||
"normal_description": "Tria el dia.",
|
"normal_description": "Tria el dia.",
|
||||||
"recurrent_1w_days": "Cada {days}",
|
"recurrent_1w_days": "Cada {days}",
|
||||||
"recurrent_2w_days": "Un de cada dos {days}",
|
"recurrent_2w_days": "Un de cada dos {days}",
|
||||||
"recurrent_1m_days": "|El dia {days} de cada mes|Els dies {days} de cada mes",
|
"recurrent_1m_days": "El dia {days} de cada mes",
|
||||||
"recurrent_2m_days": "|El dia {days} d'un de cada dos mesos|Els dies {days} d'un de cada dos mesos",
|
"recurrent_2m_days": "El dia {days} d'un de cada dos mesos",
|
||||||
"recurrent_1m_ordinal": "El {n} {days} de cada mes",
|
"recurrent_1m_ordinal": "El {n} {days} de cada mes",
|
||||||
"recurrent_2m_ordinal": "|El {n} {days} de cada dos mesos|Els {n} {days} de cada dos mesos",
|
"recurrent_2m_ordinal": "El {n} {days} de cada dos mesos",
|
||||||
"each_week": "Cada setmana",
|
"each_week": "Cada setmana",
|
||||||
"each_2w": "Cada dues setmanes",
|
"each_2w": "Cada dues setmanes",
|
||||||
"each_month": "Cada mes",
|
"each_month": "Cada mes",
|
||||||
|
|||||||
@@ -242,7 +242,7 @@
|
|||||||
"normal_description": "Wähle den Tag aus.",
|
"normal_description": "Wähle den Tag aus.",
|
||||||
"recurrent_1w_days": "Jeden {days}",
|
"recurrent_1w_days": "Jeden {days}",
|
||||||
"recurrent_2w_days": "Jeden zweiten {days} eine",
|
"recurrent_2w_days": "Jeden zweiten {days} eine",
|
||||||
"recurrent_1m_days": "|Der {days} in jedem Monat|{days} in jedem Monat",
|
"recurrent_1m_days": "Der {days} in jedem Monat",
|
||||||
"recurrent_2m_days": "Jeder {days} im Monat",
|
"recurrent_2m_days": "Jeder {days} im Monat",
|
||||||
"recurrent_1m_ordinal": "Jeden {n} {days} im Monat",
|
"recurrent_1m_ordinal": "Jeden {n} {days} im Monat",
|
||||||
"each_week": "Jede Woche",
|
"each_week": "Jede Woche",
|
||||||
|
|||||||
@@ -146,10 +146,10 @@
|
|||||||
"normal_description": "Choose the day.",
|
"normal_description": "Choose the day.",
|
||||||
"recurrent_1w_days": "Each {days}",
|
"recurrent_1w_days": "Each {days}",
|
||||||
"recurrent_2w_days": "A {days} every other",
|
"recurrent_2w_days": "A {days} every other",
|
||||||
"recurrent_1m_days": "|The {days} of each month|{days} of each month",
|
"recurrent_1m_days": "The {days} of each month",
|
||||||
"recurrent_2m_days": "|The {days} a month every other|The {days} a month every other",
|
"recurrent_2m_days": "The {days} a month every other",
|
||||||
"recurrent_1m_ordinal": "The {n} {days} of each month",
|
"recurrent_1m_ordinal": "The {n} {days} of each month",
|
||||||
"recurrent_2m_ordinal": "|The {n} {days} a month every other|The {n} {days} a month every other",
|
"recurrent_2m_ordinal": "The {n} {days} a month every other",
|
||||||
"each_week": "Each week",
|
"each_week": "Each week",
|
||||||
"each_2w": "Every other weeks",
|
"each_2w": "Every other weeks",
|
||||||
"each_month": "Each month",
|
"each_month": "Each month",
|
||||||
|
|||||||
@@ -137,10 +137,10 @@
|
|||||||
"normal_description": "Selecciona el día.",
|
"normal_description": "Selecciona el día.",
|
||||||
"recurrent_1w_days": "Cada {days}",
|
"recurrent_1w_days": "Cada {days}",
|
||||||
"recurrent_2w_days": "Un {days} cada dos",
|
"recurrent_2w_days": "Un {days} cada dos",
|
||||||
"recurrent_1m_days": "|El día {days} de cada mes|Los días {days} de cada mes",
|
"recurrent_1m_days": "El día {days} de cada mes",
|
||||||
"recurrent_2m_days": "|El día {days} cada dos meses|Los días {days} cada dos meses",
|
"recurrent_2m_days": "El día {days} cada dos meses",
|
||||||
"recurrent_1m_ordinal": "El {n} {days} de cada mes",
|
"recurrent_1m_ordinal": "El {n} {days} de cada mes",
|
||||||
"recurrent_2m_ordinal": "|El {n} {days} un mes sí y el otro no|El {n} {days} un mes sí y el otro no",
|
"recurrent_2m_ordinal": "El {n} {days} un mes sí y el otro no",
|
||||||
"each_week": "Cada semana",
|
"each_week": "Cada semana",
|
||||||
"each_2w": "Cada dos semanas",
|
"each_2w": "Cada dos semanas",
|
||||||
"each_month": "Cada mes",
|
"each_month": "Cada mes",
|
||||||
|
|||||||
@@ -142,10 +142,10 @@
|
|||||||
"normal_description": "Aukeratu eguna.",
|
"normal_description": "Aukeratu eguna.",
|
||||||
"recurrent_1w_days": "{days}(e)ro",
|
"recurrent_1w_days": "{days}(e)ro",
|
||||||
"recurrent_2w_days": "Bi {days}(e)z behin",
|
"recurrent_2w_days": "Bi {days}(e)z behin",
|
||||||
"recurrent_1m_days": "|Hilabetero {days}etan|Hilabetero {days}etan",
|
"recurrent_1m_days": "Hilabetero {days}etan",
|
||||||
"recurrent_2m_days": "|{days}etan bi hilabetez behin|{days}etan bi hilabetez behin",
|
"recurrent_2m_days": "{days}etan bi hilabetez behin",
|
||||||
"recurrent_1m_ordinal": "Hilabeteko {n}. {days}(e)ro",
|
"recurrent_1m_ordinal": "Hilabeteko {n}. {days}(e)ro",
|
||||||
"recurrent_2m_ordinal": "|Bi hilabetez behin {n}. {days}(e)an|Bi hilabetez behin {n}. {days}(e)an",
|
"recurrent_2m_ordinal": "Bi hilabetez behin {n}. {days}(e)an",
|
||||||
"each_week": "Astero",
|
"each_week": "Astero",
|
||||||
"each_2w": "Bi astez behin",
|
"each_2w": "Bi astez behin",
|
||||||
"each_month": "Hilero",
|
"each_month": "Hilero",
|
||||||
|
|||||||
@@ -104,7 +104,7 @@
|
|||||||
"from": "Du",
|
"from": "Du",
|
||||||
"each_month": "Chaque mois",
|
"each_month": "Chaque mois",
|
||||||
"each_week": "Chaque semaine",
|
"each_week": "Chaque semaine",
|
||||||
"recurrent_1m_days": "|Chaque {days} du mois|Chaque {days} du mois",
|
"recurrent_1m_days": "Chaque {days} du mois",
|
||||||
"recurrent_1w_days": "Chaque {days}",
|
"recurrent_1w_days": "Chaque {days}",
|
||||||
"normal_description": "Choisissez un jour.",
|
"normal_description": "Choisissez un jour.",
|
||||||
"normal": "Normal",
|
"normal": "Normal",
|
||||||
@@ -130,8 +130,8 @@
|
|||||||
"anon": "Anonyme",
|
"anon": "Anonyme",
|
||||||
"ics": "ICS",
|
"ics": "ICS",
|
||||||
"each_2w": "Une semaine sur deux",
|
"each_2w": "Une semaine sur deux",
|
||||||
"recurrent_2m_ordinal": "|Le {n} {days} du mois un mois sur|Les {n} {days} du mois un mois sur deux",
|
"recurrent_2m_ordinal": "Les {n} {days} du mois un mois sur deux",
|
||||||
"recurrent_2m_days": "|Le {days} un mois sur deux|Les {jours} un mois sur deux",
|
"recurrent_2m_days": "Le {days} un mois sur deux",
|
||||||
"recurrent_2w_days": "Un {days} sur deux",
|
"recurrent_2w_days": "Un {days} sur deux",
|
||||||
"edit_recurrent": "Modifier l’évènement récurrent :",
|
"edit_recurrent": "Modifier l’évènement récurrent :",
|
||||||
"updated": "Évènement mis à jour",
|
"updated": "Évènement mis à jour",
|
||||||
|
|||||||
@@ -119,8 +119,8 @@
|
|||||||
"show_past": "tamén eventos previos",
|
"show_past": "tamén eventos previos",
|
||||||
"only_future": "só eventos futuros",
|
"only_future": "só eventos futuros",
|
||||||
"recurrent_2w_days": "Cada {days} días",
|
"recurrent_2w_days": "Cada {days} días",
|
||||||
"recurrent_2m_ordinal": "|O {n} {days} en meses alternos|O {n} {days} en meses alternos",
|
"recurrent_2m_ordinal": "O {n} {days} en meses alternos",
|
||||||
"recurrent_2m_days": "|O {days} cada dous meses|O {days} cada dous meses",
|
"recurrent_2m_days": "O {days} cada dous meses",
|
||||||
"each_month": "Cada mes",
|
"each_month": "Cada mes",
|
||||||
"due": "ata",
|
"due": "ata",
|
||||||
"from": "Desde",
|
"from": "Desde",
|
||||||
@@ -149,7 +149,7 @@
|
|||||||
"recurrent_1w_days": "Cada {days}",
|
"recurrent_1w_days": "Cada {days}",
|
||||||
"recurrent_1m_ordinal": "O {n} {days} de cada mes",
|
"recurrent_1m_ordinal": "O {n} {days} de cada mes",
|
||||||
"image_too_big": "A imaxe non pode superar os 4MB",
|
"image_too_big": "A imaxe non pode superar os 4MB",
|
||||||
"recurrent_1m_days": "|O {days} de cada mes|{days} de cada mes",
|
"recurrent_1m_days": "O {days} de cada mes",
|
||||||
"each_2w": "Cada dúas semanas",
|
"each_2w": "Cada dúas semanas",
|
||||||
"follow_me_description": "Un dos xeitos de recibir actualizacións dos eventos que se publican aquí en {title},\né seguindo a conta <u>{account}</u> no fediverso, por exemplo a través de Mastodon, e posiblemente tamén engadir recursos para un evento desde alí.<br/><br/>\nSe nunco escoitaches falar de Mastodon e o fediverso recomendámosche ler <a href='https://www.savjee.be/videos/simply-explained/mastodon-and-fediverse-explained/'>este artigo</a>.<br/><br/>Escribe aquí a túa instancia (ex. mastodon.social)",
|
"follow_me_description": "Un dos xeitos de recibir actualizacións dos eventos que se publican aquí en {title},\né seguindo a conta <u>{account}</u> no fediverso, por exemplo a través de Mastodon, e posiblemente tamén engadir recursos para un evento desde alí.<br/><br/>\nSe nunco escoitaches falar de Mastodon e o fediverso recomendámosche ler <a href='https://www.savjee.be/videos/simply-explained/mastodon-and-fediverse-explained/'>este artigo</a>.<br/><br/>Escribe aquí a túa instancia (ex. mastodon.social)",
|
||||||
"ics": "ICS",
|
"ics": "ICS",
|
||||||
|
|||||||
@@ -114,8 +114,8 @@
|
|||||||
"image_too_big": "Bildet kan ikke være større enn 4 MB",
|
"image_too_big": "Bildet kan ikke være større enn 4 MB",
|
||||||
"recurrent_2m_ordinal": "|Den {n} {days} i måneden annenhver|Den {n} {days} i måneden annenhver",
|
"recurrent_2m_ordinal": "|Den {n} {days} i måneden annenhver|Den {n} {days} i måneden annenhver",
|
||||||
"recurrent_1m_ordinal": "På {n} {days} i hver måned",
|
"recurrent_1m_ordinal": "På {n} {days} i hver måned",
|
||||||
"recurrent_2m_days": "|På {days} i hver måned annenhver|{days} i hver måned annenhver",
|
"recurrent_2m_days": "På {days} i hver måned annenhver",
|
||||||
"recurrent_1m_days": "|På {days} i hver måned|{days} i hver måned",
|
"recurrent_1m_days": "På {days} i hver måned",
|
||||||
"recurrent_2w_days": "En {days} annenhver",
|
"recurrent_2w_days": "En {days} annenhver",
|
||||||
"multidate_description": "Er det en festival? Velg når den starter og slutter",
|
"multidate_description": "Er det en festival? Velg når den starter og slutter",
|
||||||
"where_description": "Hvor finner hendelsen sted? Hvis den ikke finnes kan du opprette den.",
|
"where_description": "Hvor finner hendelsen sted? Hvis den ikke finnes kan du opprette den.",
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ v-container.container.pa-0.pa-md-3
|
|||||||
WhereInput(ref='where' v-model='event.place')
|
WhereInput(ref='where' v-model='event.place')
|
||||||
|
|
||||||
//- When
|
//- When
|
||||||
DateInput(v-model='date' :event='event')
|
DateInput(ref='when' v-model='date' :event='event')
|
||||||
//- Description
|
//- Description
|
||||||
v-col.px-0(cols='12')
|
v-col.px-0(cols='12')
|
||||||
Editor.px-3.ma-0(
|
Editor.px-3.ma-0(
|
||||||
@@ -112,7 +112,7 @@ export default {
|
|||||||
data.date = {
|
data.date = {
|
||||||
recurrent: event.recurrent,
|
recurrent: event.recurrent,
|
||||||
from: dayjs.unix(event.start_datetime).toDate(),
|
from: dayjs.unix(event.start_datetime).toDate(),
|
||||||
due: dayjs.unix(event.end_datetime).toDate(),
|
due: event.end_datetime && dayjs.unix(event.end_datetime).toDate(),
|
||||||
multidate: event.multidate,
|
multidate: event.multidate,
|
||||||
fromHour: true,
|
fromHour: true,
|
||||||
dueHour: true
|
dueHour: true
|
||||||
@@ -172,11 +172,13 @@ export default {
|
|||||||
}, 100),
|
}, 100),
|
||||||
eventImported(event) {
|
eventImported(event) {
|
||||||
this.event = Object.assign(this.event, event)
|
this.event = Object.assign(this.event, event)
|
||||||
this.$refs.where.selectPlace({ name: event.place.name || event.place, create: true })
|
|
||||||
|
this.$refs.where.selectPlace({ name: event.place.name || event.place, address: event.place.address })
|
||||||
|
|
||||||
this.date = {
|
this.date = {
|
||||||
recurrent: this.event.recurrent || null,
|
recurrent: this.event.recurrent || null,
|
||||||
from: new Date(dayjs.unix(this.event.start_datetime)),
|
from: dayjs.unix(this.event.start_datetime).toDate(),
|
||||||
due: new Date(dayjs.unix(this.event.end_datetime)),
|
due: this.event.end_datetime && dayjs.unix(this.event.end_datetime).toDate(),
|
||||||
multidate: event.multidate,
|
multidate: event.multidate,
|
||||||
fromHour: true,
|
fromHour: true,
|
||||||
dueHour: true
|
dueHour: true
|
||||||
|
|||||||
@@ -1,132 +1,4 @@
|
|||||||
const log = require('../log')
|
const log = require('../log')
|
||||||
const get = require('lodash/get')
|
|
||||||
const passport = require('passport')
|
|
||||||
|
|
||||||
// const oauth = require('./oauth')
|
|
||||||
// const User = require('./models/user')
|
|
||||||
// const OAuthClient = require('./models/oauth_client')
|
|
||||||
// const OAuthCode = require('./models/oauth_code')
|
|
||||||
// const OAuthToken = require('./models/oauth_token')
|
|
||||||
|
|
||||||
|
|
||||||
// const CustomStrategy = require('passport-custom').Strategy
|
|
||||||
// const LocalStrategy = require('passport-local').Strategy
|
|
||||||
// const BasicStrategy = require('passport-http').BasicStrategy
|
|
||||||
// const ClientPasswordStrategy = require('passport-oauth2-client-password').Strategy
|
|
||||||
// const BearerStrategy = require('passport-http-bearer').Strategy
|
|
||||||
|
|
||||||
// console.error('dentro passport setup!')
|
|
||||||
// passport.use('authenticate', new CustomStrategy(async (req, done) => {
|
|
||||||
// console.error('dentro authenticate strategy')
|
|
||||||
|
|
||||||
// // check if a cookie is passed
|
|
||||||
// const token = get(req.cookies, 'auth._token.local', null)
|
|
||||||
// const authorization = get(req.headers, 'authorization', null)
|
|
||||||
// if (!authorization && token) {
|
|
||||||
// req.headers.authorization = token
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (!authorization && !token) {
|
|
||||||
// return done(null, false)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// console.error(authorization, token)
|
|
||||||
// return done(null, false)
|
|
||||||
|
|
||||||
// }))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* LocalStrategy
|
|
||||||
*
|
|
||||||
* This strategy is used to authenticate users based on a username and password.
|
|
||||||
* Anytime a request is made to authorize an application, we must ensure that
|
|
||||||
* a user is logged in before asking them to approve the request.
|
|
||||||
*/
|
|
||||||
// passport.use(new LocalStrategy(
|
|
||||||
// async (username, password, done) => {
|
|
||||||
// console.error(`sono qui dentro local strategy cerco ${username} ${password}}`)
|
|
||||||
// const user = await User.findOne({ where: { email: username, is_active: true } })
|
|
||||||
// console.error(user)
|
|
||||||
// if (!user) {
|
|
||||||
// return done(null, false)
|
|
||||||
// }
|
|
||||||
// // check if password matches
|
|
||||||
// if (await user.comparePassword(password)) {
|
|
||||||
// console.error('compare password ok!')
|
|
||||||
// return done(null, user)
|
|
||||||
// }
|
|
||||||
// return done(null, false)
|
|
||||||
// }
|
|
||||||
// // ))
|
|
||||||
|
|
||||||
// passport.serializeUser((user, done) => done(null, user.id))
|
|
||||||
|
|
||||||
// passport.deserializeUser(async (id, done) => {
|
|
||||||
// const user = await User.findByPk(id)
|
|
||||||
// done(null, user)
|
|
||||||
// })
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BasicStrategy & ClientPasswordStrategy
|
|
||||||
*
|
|
||||||
* These strategies are used to authenticate registered OAuth clients. They are
|
|
||||||
* employed to protect the `token` endpoint, which consumers use to obtain
|
|
||||||
* access tokens. The OAuth 2.0 specification suggests that clients use the
|
|
||||||
* HTTP Basic scheme to authenticate. Use of the client password strategy
|
|
||||||
* allows clients to send the same credentials in the request body (as opposed
|
|
||||||
* to the `Authorization` header). While this approach is not recommended by
|
|
||||||
* the specification, in practice it is quite common.
|
|
||||||
*/
|
|
||||||
// async function verifyClient(client_id, client_secret, done) {
|
|
||||||
// console.error('Dentro verify client ', client_id, client_secret)
|
|
||||||
// const client = await OAuthClient.findByPk(client_id, { raw: true })
|
|
||||||
// console.error(client)
|
|
||||||
// if (client_secret && client_secret !== client.client_secret) {
|
|
||||||
// return done(null, false)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (client) { client.grants = ['authorization_code', 'password'] } //sure ?
|
|
||||||
|
|
||||||
// return done(null, client)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// passport.use(new BasicStrategy(verifyClient))
|
|
||||||
// passport.use(new ClientPasswordStrategy(verifyClient))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BearerStrategy
|
|
||||||
*
|
|
||||||
* This strategy is used to authenticate either users or clients based on an access token
|
|
||||||
* (aka a bearer token). If a user, they must have previously authorized a client
|
|
||||||
* application, which is issued an access token to make requests on behalf of
|
|
||||||
* the authorizing user.
|
|
||||||
*/
|
|
||||||
// passport.use(new BearerStrategy(
|
|
||||||
// async (accessToken, done) => {
|
|
||||||
// console.error('dentro bearer strategy')
|
|
||||||
// const token = await OAuthToken.findByPk(accessToken,
|
|
||||||
// { include: [{ model: User, attributes: { exclude: ['password'] } }, { model: OAuthClient, as: 'client' }] })
|
|
||||||
|
|
||||||
// if (!token) return done(null, false)
|
|
||||||
// if (token.userId) {
|
|
||||||
// if (!token.user) {
|
|
||||||
// return done(null, false)
|
|
||||||
// }
|
|
||||||
// // To keep this example simple, restricted scopes are not implemented,
|
|
||||||
// // and this is just for illustrative purposes.
|
|
||||||
// done(null, user, { scope: '*' })
|
|
||||||
// } else {
|
|
||||||
// // The request came from a client only since userId is null,
|
|
||||||
// // therefore the client is passed back instead of a user.
|
|
||||||
// if (!token.client) {
|
|
||||||
// return done(null, false)
|
|
||||||
// }
|
|
||||||
// // To keep this example simple, restricted scopes are not implemented,
|
|
||||||
// // and this is just for illustrative purposes.
|
|
||||||
// done(null, client, { scope: '*' })
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// ))
|
|
||||||
|
|
||||||
const Auth = {
|
const Auth = {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user