Revert "add TOTP/Recovery Form for mobile version"
This reverts commit a3811f944819430c278b6da6b08dc322a9b9ff65.
This commit is contained in:
parent
9df99c5205
commit
77eceedbf7
32 changed files with 1657 additions and 439 deletions
|
@ -17,6 +17,13 @@ const ADMIN_USERS_URL = '/api/pleroma/admin/users'
|
|||
const SUGGESTIONS_URL = '/api/v1/suggestions'
|
||||
const NOTIFICATION_SETTINGS_URL = '/api/pleroma/notification_settings'
|
||||
|
||||
const MFA_SETTINGS_URL = '/api/pleroma/profile/mfa'
|
||||
const MFA_BACKUP_CODES_URL = '/api/pleroma/profile/mfa/backup_codes'
|
||||
|
||||
const MFA_SETUP_OTP_URL = '/api/pleroma/profile/mfa/setup/totp'
|
||||
const MFA_CONFIRM_OTP_URL = '/api/pleroma/profile/mfa/confirm/totp'
|
||||
const MFA_DISABLE_OTP_URL = '/api/pleroma/profile/mfa/totp'
|
||||
|
||||
const MASTODON_LOGIN_URL = '/api/v1/accounts/verify_credentials'
|
||||
const MASTODON_USER_FAVORITES_TIMELINE_URL = '/api/v1/favourites'
|
||||
const MASTODON_USER_NOTIFICATIONS_URL = '/api/v1/notifications'
|
||||
|
@ -649,6 +656,51 @@ const changePassword = ({credentials, password, newPassword, newPasswordConfirma
|
|||
.then((response) => response.json())
|
||||
}
|
||||
|
||||
const settingsMFA = ({credentials}) => {
|
||||
return fetch(MFA_SETTINGS_URL, {
|
||||
headers: authHeaders(credentials),
|
||||
method: 'GET'
|
||||
}).then((data) => data.json())
|
||||
}
|
||||
|
||||
const mfaDisableOTP = ({credentials, password}) => {
|
||||
const form = new FormData()
|
||||
|
||||
form.append('password', password)
|
||||
|
||||
return fetch(MFA_DISABLE_OTP_URL, {
|
||||
body: form,
|
||||
method: 'DELETE',
|
||||
headers: authHeaders(credentials)
|
||||
})
|
||||
.then((response) => response.json())
|
||||
}
|
||||
|
||||
const mfaConfirmOTP = ({credentials, password, token}) => {
|
||||
const form = new FormData()
|
||||
|
||||
form.append('password', password)
|
||||
form.append('code', token)
|
||||
|
||||
return fetch(MFA_CONFIRM_OTP_URL, {
|
||||
body: form,
|
||||
headers: authHeaders(credentials),
|
||||
method: 'POST'
|
||||
}).then((data) => data.json())
|
||||
}
|
||||
const mfaSetupOTP = ({credentials}) => {
|
||||
return fetch(MFA_SETUP_OTP_URL, {
|
||||
headers: authHeaders(credentials),
|
||||
method: 'GET'
|
||||
}).then((data) => data.json())
|
||||
}
|
||||
const generateMfaBackupCodes = ({credentials}) => {
|
||||
return fetch(MFA_BACKUP_CODES_URL, {
|
||||
headers: authHeaders(credentials),
|
||||
method: 'GET'
|
||||
}).then((data) => data.json())
|
||||
}
|
||||
|
||||
const fetchMutes = ({credentials}) => {
|
||||
return promisedRequest({ url: MASTODON_USER_MUTES_URL, credentials })
|
||||
.then((users) => users.map(parseUser))
|
||||
|
@ -776,6 +828,11 @@ const apiService = {
|
|||
importFollows,
|
||||
deleteAccount,
|
||||
changePassword,
|
||||
settingsMFA,
|
||||
mfaDisableOTP,
|
||||
generateMfaBackupCodes,
|
||||
mfaSetupOTP,
|
||||
mfaConfirmOTP,
|
||||
fetchFollowRequests,
|
||||
approveUser,
|
||||
denyUser,
|
||||
|
|
|
@ -116,6 +116,12 @@ const backendInteractorService = (credentials) => {
|
|||
const deleteAccount = ({password}) => apiService.deleteAccount({credentials, password})
|
||||
const changePassword = ({password, newPassword, newPasswordConfirmation}) => apiService.changePassword({credentials, password, newPassword, newPasswordConfirmation})
|
||||
|
||||
const fetchSettingsMFA = () => apiService.settingsMFA({credentials})
|
||||
const generateMfaBackupCodes = () => apiService.generateMfaBackupCodes({credentials})
|
||||
const mfaSetupOTP = () => apiService.mfaSetupOTP({credentials})
|
||||
const mfaConfirmOTP = ({password, token}) => apiService.mfaConfirmOTP({credentials, password, token})
|
||||
const mfaDisableOTP = ({password}) => apiService.mfaDisableOTP({credentials, password})
|
||||
|
||||
const fetchFavoritedByUsers = (id) => apiService.fetchFavoritedByUsers({id})
|
||||
const fetchRebloggedByUsers = (id) => apiService.fetchRebloggedByUsers({id})
|
||||
const reportUser = (params) => apiService.reportUser({credentials, ...params})
|
||||
|
@ -166,6 +172,11 @@ const backendInteractorService = (credentials) => {
|
|||
importFollows,
|
||||
deleteAccount,
|
||||
changePassword,
|
||||
fetchSettingsMFA,
|
||||
generateMfaBackupCodes,
|
||||
mfaSetupOTP,
|
||||
mfaConfirmOTP,
|
||||
mfaDisableOTP,
|
||||
fetchFollowRequests,
|
||||
approveUser,
|
||||
denyUser,
|
||||
|
|
38
src/services/new_api/mfa.js
Normal file
38
src/services/new_api/mfa.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
const verifyOTPCode = ({app, instance, mfaToken, code}) => {
|
||||
const url = `${instance}/oauth/mfa/challenge`
|
||||
const form = new window.FormData()
|
||||
|
||||
form.append('client_id', app.client_id)
|
||||
form.append('client_secret', app.client_secret)
|
||||
form.append('mfa_token', mfaToken)
|
||||
form.append('code', code)
|
||||
form.append('challenge_type', 'totp')
|
||||
|
||||
return window.fetch(url, {
|
||||
method: 'POST',
|
||||
body: form
|
||||
}).then((data) => data.json())
|
||||
}
|
||||
|
||||
const verifyRecoveryCode = ({app, instance, mfaToken, code}) => {
|
||||
const url = `${instance}/oauth/mfa/challenge`
|
||||
const form = new window.FormData()
|
||||
|
||||
form.append('client_id', app.client_id)
|
||||
form.append('client_secret', app.client_secret)
|
||||
form.append('mfa_token', mfaToken)
|
||||
form.append('code', code)
|
||||
form.append('challenge_type', 'recovery')
|
||||
|
||||
return window.fetch(url, {
|
||||
method: 'POST',
|
||||
body: form
|
||||
}).then((data) => data.json())
|
||||
}
|
||||
|
||||
const mfa = {
|
||||
verifyOTPCode,
|
||||
verifyRecoveryCode
|
||||
}
|
||||
|
||||
export default mfa
|
|
@ -71,12 +71,45 @@ const getToken = ({app, instance, code}) => {
|
|||
body: form
|
||||
}).then((data) => data.json())
|
||||
}
|
||||
const verifyOTPCode = ({app, instance, mfaToken, code}) => {
|
||||
const url = `${instance}/oauth/mfa/challenge`
|
||||
const form = new window.FormData()
|
||||
|
||||
form.append('client_id', app.client_id)
|
||||
form.append('client_secret', app.client_secret)
|
||||
form.append('mfa_token', mfaToken)
|
||||
form.append('code', code)
|
||||
form.append('challenge_type', 'totp')
|
||||
|
||||
return window.fetch(url, {
|
||||
method: 'POST',
|
||||
body: form
|
||||
}).then((data) => data.json())
|
||||
}
|
||||
|
||||
const verifyRecoveryCode = ({app, instance, mfaToken, code}) => {
|
||||
const url = `${instance}/oauth/mfa/challenge`
|
||||
const form = new window.FormData()
|
||||
|
||||
form.append('client_id', app.client_id)
|
||||
form.append('client_secret', app.client_secret)
|
||||
form.append('mfa_token', mfaToken)
|
||||
form.append('code', code)
|
||||
form.append('challenge_type', 'recovery')
|
||||
|
||||
return window.fetch(url, {
|
||||
method: 'POST',
|
||||
body: form
|
||||
}).then((data) => data.json())
|
||||
}
|
||||
|
||||
const oauth = {
|
||||
login,
|
||||
getToken,
|
||||
getTokenWithCredentials,
|
||||
getOrCreateApp
|
||||
getOrCreateApp,
|
||||
verifyOTPCode,
|
||||
verifyRecoveryCode
|
||||
}
|
||||
|
||||
export default oauth
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue