Added ability to set password for groups
• Added: - ability to set password for groups - GroupPasswordModal - checks for if has password - rate limiting in rack_attack
This commit is contained in:
@@ -10,6 +10,7 @@ export const GROUP_UPDATE_SUCCESS = 'GROUP_UPDATE_SUCCESS'
|
||||
export const GROUP_UPDATE_FAIL = 'GROUP_UPDATE_FAIL'
|
||||
|
||||
export const GROUP_EDITOR_TITLE_CHANGE = 'GROUP_EDITOR_TITLE_CHANGE'
|
||||
export const GROUP_EDITOR_PASSWORD_CHANGE = 'GROUP_EDITOR_PASSWORD_CHANGE'
|
||||
export const GROUP_EDITOR_DESCRIPTION_CHANGE = 'GROUP_EDITOR_DESCRIPTION_CHANGE'
|
||||
export const GROUP_EDITOR_COVER_IMAGE_CHANGE = 'GROUP_EDITOR_COVER_IMAGE_CHANGE'
|
||||
export const GROUP_EDITOR_ID_CHANGE = 'GROUP_EDITOR_ID_CHANGE'
|
||||
@@ -33,10 +34,12 @@ export const submit = (routerHistory) => (dispatch, getState) => {
|
||||
const category = getState().getIn(['group_editor', 'category'])
|
||||
const isPrivate = getState().getIn(['group_editor', 'isPrivate'])
|
||||
const isVisible = getState().getIn(['group_editor', 'isVisible'])
|
||||
const slug = getState().getIn(['group_editor', 'id'])
|
||||
const slug = getState().getIn(['group_editor', 'id'], null)
|
||||
const password = getState().getIn(['group_editor', 'password'], null)
|
||||
|
||||
const options = {
|
||||
title,
|
||||
password,
|
||||
description,
|
||||
coverImage,
|
||||
tags,
|
||||
@@ -65,6 +68,7 @@ const create = (options, routerHistory) => (dispatch, getState) => {
|
||||
formData.append('group_category_id', options.category)
|
||||
formData.append('is_private', options.isPrivate)
|
||||
formData.append('is_visible', options.isVisible)
|
||||
formData.append('password', options.password)
|
||||
|
||||
if (options.coverImage !== null) {
|
||||
formData.append('cover_image', options.coverImage)
|
||||
@@ -108,8 +112,11 @@ const update = (groupId, options, routerHistory) => (dispatch, getState) => {
|
||||
formData.append('group_category_id', options.category)
|
||||
formData.append('is_private', options.isPrivate)
|
||||
formData.append('is_visible', options.isVisible)
|
||||
formData.append('slug', options.slug)
|
||||
formData.append('password', options.password)
|
||||
|
||||
if (!!options.slug) {
|
||||
formData.append('slug', options.slug)
|
||||
}
|
||||
if (options.coverImage !== null) {
|
||||
formData.append('cover_image', options.coverImage)
|
||||
}
|
||||
@@ -153,6 +160,11 @@ export const changeGroupTitle = (title) => ({
|
||||
title,
|
||||
})
|
||||
|
||||
export const changeGroupPassword = (password) => ({
|
||||
type: GROUP_EDITOR_PASSWORD_CHANGE,
|
||||
password,
|
||||
})
|
||||
|
||||
export const changeGroupDescription = (description) => ({
|
||||
type: GROUP_EDITOR_DESCRIPTION_CHANGE,
|
||||
description,
|
||||
|
||||
@@ -77,6 +77,11 @@ export const GROUP_UPDATE_ROLE_REQUEST = 'GROUP_UPDATE_ROLE_REQUEST';
|
||||
export const GROUP_UPDATE_ROLE_SUCCESS = 'GROUP_UPDATE_ROLE_SUCCESS';
|
||||
export const GROUP_UPDATE_ROLE_FAIL = 'GROUP_UPDATE_ROLE_FAIL';
|
||||
|
||||
export const GROUP_CHECK_PASSWORD_RESET = 'GROUP_CHECK_PASSWORD_RESET';
|
||||
export const GROUP_CHECK_PASSWORD_REQUEST = 'GROUP_CHECK_PASSWORD_REQUEST';
|
||||
export const GROUP_CHECK_PASSWORD_SUCCESS = 'GROUP_CHECK_PASSWORD_SUCCESS';
|
||||
export const GROUP_CHECK_PASSWORD_FAIL = 'GROUP_CHECK_PASSWORD_FAIL';
|
||||
|
||||
export const GROUP_PIN_STATUS_REQUEST = 'GROUP_PIN_STATUS_REQUEST'
|
||||
export const GROUP_PIN_STATUS_SUCCESS = 'GROUP_PIN_STATUS_SUCCESS'
|
||||
export const GROUP_PIN_STATUS_FAIL = 'GROUP_PIN_STATUS_FAIL'
|
||||
@@ -609,6 +614,45 @@ export function updateRoleFail(groupId, id, error) {
|
||||
};
|
||||
};
|
||||
|
||||
export function checkGroupPassword(groupId, password) {
|
||||
return (dispatch, getState) => {
|
||||
if (!me) return
|
||||
|
||||
dispatch(checkGroupPasswordRequest())
|
||||
|
||||
api(getState).post(`/api/v1/groups/${groupId}/password`, { password }).then((response) => {
|
||||
dispatch(joinGroupSuccess(response.data))
|
||||
dispatch(checkGroupPasswordSuccess())
|
||||
}).catch(error => {
|
||||
dispatch(checkGroupPasswordFail(error))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export function checkGroupPasswordReset() {
|
||||
return {
|
||||
type: GROUP_CHECK_PASSWORD_RESET,
|
||||
}
|
||||
}
|
||||
|
||||
export function checkGroupPasswordRequest() {
|
||||
return {
|
||||
type: GROUP_CHECK_PASSWORD_REQUEST,
|
||||
}
|
||||
}
|
||||
|
||||
export function checkGroupPasswordSuccess() {
|
||||
return {
|
||||
type: GROUP_CHECK_PASSWORD_SUCCESS,
|
||||
}
|
||||
}
|
||||
|
||||
export function checkGroupPasswordFail(error) {
|
||||
return {
|
||||
type: GROUP_CHECK_PASSWORD_FAIL,
|
||||
error,
|
||||
}
|
||||
}
|
||||
|
||||
export function fetchJoinRequests(id) {
|
||||
return (dispatch, getState) => {
|
||||
|
||||
Reference in New Issue
Block a user