Add a registration form.

This commit is contained in:
Roger Braun 2017-04-15 18:12:23 +02:00
parent 6d7fcb057d
commit a766e886f5
7 changed files with 169 additions and 16 deletions

View file

@ -10,15 +10,18 @@ const RETWEET_URL = '/api/statuses/retweet'
const STATUS_UPDATE_URL = '/api/statuses/update.json'
const STATUS_DELETE_URL = '/api/statuses/destroy'
const STATUS_URL = '/api/statuses/show'
const MEDIA_UPLOAD_URL = '/api/statusnet/media/upload'
const MEDIA_UPLOAD_URL = '/api/media/upload.json'
const CONVERSATION_URL = '/api/statusnet/conversation'
const MENTIONS_URL = '/api/statuses/mentions.json'
const FRIENDS_URL = '/api/statuses/friends.json'
const FOLLOWING_URL = '/api/friendships/create.json'
const UNFOLLOWING_URL = '/api/friendships/destroy.json'
const QVITTER_USER_PREF_URL = '/api/qvitter/set_profile_pref.json'
const REGISTRATION_URL = '/api/account/register.json'
// const USER_URL = '/api/users/show.json'
import { each } from 'lodash'
const oldfetch = window.fetch
let fetch = (url, options) => {
@ -27,6 +30,32 @@ let fetch = (url, options) => {
return oldfetch(fullUrl, options)
}
// Params needed:
// nickname
// email
// fullname
// password
// password_confirm
//
// Optional
// bio
// homepage
// location
const register = (params) => {
const form = new FormData()
each(params, (value, key) => {
if (value) {
form.append(key, value)
}
})
return fetch(REGISTRATION_URL, {
method: 'POST',
body: form
})
}
const authHeaders = (user) => {
if (user && user.username && user.password) {
return { 'Authorization': `Basic ${btoa(`${user.username}:${user.password}`)}` }
@ -198,7 +227,8 @@ const apiService = {
uploadMedia,
fetchAllFollowing,
setUserMute,
fetchMutes
fetchMutes,
register
}
export default apiService