chore: Unify term types

This commit is contained in:
Maksim Eltyshev
2026-02-10 21:14:56 +01:00
parent e7326303cd
commit a82ae49fe4
14 changed files with 31 additions and 176 deletions
@@ -31,7 +31,7 @@
* type: string
* minLength: 64
* maxLength: 64
* description: Terms signature hash based on user role
* description: Terms signature hash
* example: 940226c4c41f51afe3980ceb63704e752636526f4c52a4ea579e85b247493d94
* initialLanguage:
* type: string
@@ -184,14 +184,12 @@ module.exports = {
}
if (!user.termsSignature) {
const termsSignature = sails.hooks.terms.getSignatureByUserRole(user.role);
if (inputs.signature !== termsSignature) {
if (!sails.hooks.terms.isSignatureValid(inputs.signature)) {
throw Errors.INVALID_SIGNATURE;
}
const values = {
termsSignature,
termsSignature: inputs.signature,
termsAcceptedAt: new Date().toISOString(),
};
+2 -20
View File
@@ -5,7 +5,7 @@
/**
* @swagger
* /terms/{type}:
* /terms:
* get:
* summary: Get terms and conditions
* description: Retrieves terms and conditions in the specified language.
@@ -13,14 +13,6 @@
* - Terms
* operationId: getTerms
* parameters:
* - name: type
* in: path
* required: true
* description: Type of terms to retrieve
* schema:
* type: string
* enum: [general, extended]
* example: general
* - name: language
* in: query
* required: false
@@ -47,11 +39,6 @@
* - content
* - signature
* properties:
* type:
* type: string
* enum: [general, extended]
* description: Type of terms
* example: general
* language:
* type: string
* enum: [de-DE, en-US]
@@ -76,11 +63,6 @@
module.exports = {
inputs: {
type: {
type: 'string',
isIn: Object.values(sails.hooks.terms.Types),
required: true,
},
language: {
type: 'string',
isIn: User.LANGUAGES,
@@ -88,7 +70,7 @@ module.exports = {
},
async fn(inputs) {
const terms = await sails.hooks.terms.getPayload(inputs.type, inputs.language);
const terms = await sails.hooks.terms.getPayload(inputs.language);
return {
item: terms,