Add limit login category support

This commit is contained in:
Jonas Lochmann
2020-06-29 02:00:00 +02:00
parent 7e7caae583
commit 5574ad415c
25 changed files with 666 additions and 51 deletions
+1
View File
@@ -67,3 +67,4 @@ export { UpdateParentBlockedTimesAction } from './updateparentblockedtimes'
export { UpdateParentNotificationFlagsAction } from './updateparentnotificationflags'
export { UpdateTimelimitRuleAction } from './updatetimelimitrule'
export { UpdateUserFlagsAction } from './updateuserflags'
export { UpdateUserLimitLoginCategory } from './updateuserlimitlogincategory'
+5 -1
View File
@@ -56,6 +56,7 @@ import { SerializedUpdateParentBlockedTimesAction, UpdateParentBlockedTimesActio
import { SerializedUpdateParentNotificationFlagsAction, UpdateParentNotificationFlagsAction } from '../updateparentnotificationflags'
import { SerializedUpdateTimelimitRuleAction, UpdateTimelimitRuleAction } from '../updatetimelimitrule'
import { SerializedUpdateUserFlagsAction, UpdateUserFlagsAction } from '../updateuserflags'
import { SerializedUpdateUserLimitLoginCategory, UpdateUserLimitLoginCategory } from '../updateuserlimitlogincategory'
export type SerializedParentAction =
SerializedAddCategoryAppsAction |
@@ -97,7 +98,8 @@ export type SerializedParentAction =
SerializedUpdateParentBlockedTimesAction |
SerializedUpdateParentNotificationFlagsAction |
SerializedUpdateTimelimitRuleAction |
SerializedUpdateUserFlagsAction
SerializedUpdateUserFlagsAction |
SerializedUpdateUserLimitLoginCategory
export const parseParentAction = (action: SerializedParentAction): ParentAction => {
if (action.type === 'ADD_CATEGORY_APPS') {
@@ -180,6 +182,8 @@ export const parseParentAction = (action: SerializedParentAction): ParentAction
return UpdateTimelimitRuleAction.parse(action)
} else if (action.type === 'UPDATE_USER_FLAGS') {
return UpdateUserFlagsAction.parse(action)
} else if (action.type === 'UPDATE_USER_LIMIT_LOGIN_CATEGORY') {
return UpdateUserLimitLoginCategory.parse(action)
} else {
throw new Error('illegal state: invalid type for action at parseParentAction')
}
@@ -0,0 +1,59 @@
/*
* server component for the TimeLimit App
* Copyright (C) 2019 - 2020 Jonas Lochmann
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { assertIdWithinFamily } from '../util/token'
import { ParentAction } from './basetypes'
export class UpdateUserLimitLoginCategory extends ParentAction {
readonly userId: string
readonly categoryId?: string
constructor ({ userId, categoryId }: {
userId: string,
categoryId?: string
}) {
super()
assertIdWithinFamily(userId)
if (categoryId !== undefined) {
assertIdWithinFamily(categoryId)
}
this.userId = userId
this.categoryId = categoryId
}
serialize = (): SerializedUpdateUserLimitLoginCategory => ({
type: 'UPDATE_USER_LIMIT_LOGIN_CATEGORY',
userId: this.userId,
categoryId: this.categoryId
})
static parse = ({ userId, categoryId }: SerializedUpdateUserLimitLoginCategory) => (
new UpdateUserLimitLoginCategory({
userId,
categoryId
})
)
}
export interface SerializedUpdateUserLimitLoginCategory {
type: 'UPDATE_USER_LIMIT_LOGIN_CATEGORY'
userId: string
categoryId?: string
}