From 4c1ad256efd8c345f957bd598644c097cfaaf006 Mon Sep 17 00:00:00 2001 From: martin bedouret Date: Mon, 22 Jan 2018 19:11:00 -0300 Subject: [PATCH 1/2] add app langs --- api/constants/index.js | 50 +++++++++++++++++++ api/swagger/swagger.yaml | 13 +---- test/cboard-api.postman_collection.json | 66 +++++++++++++++++++++++-- 3 files changed, 114 insertions(+), 15 deletions(-) create mode 100644 api/constants/index.js diff --git a/api/constants/index.js b/api/constants/index.js new file mode 100644 index 00000000..b52c012a --- /dev/null +++ b/api/constants/index.js @@ -0,0 +1,50 @@ + + +const DEFAULT_LANG = 'en-US'; +const APP_LANGS = [ + 'ar-SA', + 'bn-BD', + 'cs-CZ', + 'da-DK', + 'de-DE', + 'el-GR', + 'en-US', + 'en-GB', + 'es-ES', + 'fi-FI', + 'fr-FR', + 'he-IL', + 'hi-IN', + 'hu-HU', + 'id-ID', + 'it-IT', + 'ja-JP', + 'km-KH', + 'ko-KR', + 'ne-NP', + 'nl-NL', + 'no-NO', + 'pl-PL', + 'pt-BR', + 'pt-PT', + 'ro-RO', + 'ru-RU', + 'si-LK', + 'sk-SK', + 'sv-SE', + 'th-TH', + 'tr-TR', + 'uk-UA', + 'vi-VN', + 'zh-CN', + 'zu-ZA' // for crowdin contextual translation +]; + +/** + * Expose + */ + +module.exports = { + DEFAULT_LANG: DEFAULT_LANG, + APP_LANGS: APP_LANGS + }; diff --git a/api/swagger/swagger.yaml b/api/swagger/swagger.yaml index 5764c642..6d3a534d 100644 --- a/api/swagger/swagger.yaml +++ b/api/swagger/swagger.yaml @@ -56,8 +56,7 @@ parameters: type: string locale: type: string - enum: ["da", "nl", "en", "fi", "fr", "de", "hu", "it", "nb", "pt", "ro", "ru", "es", "sv", "tr", "ara", "prs", "pes", "urd", "zhs", "zht", "none"] - + enum: &APP_LANGS ['ar-SA','bn-BD','cs-CZ','da-DK','de-DE','el-GR','en-US','en-GB','es-ES','fi-FI','fr-FR','he-IL','hi-IN','hu-HU','id-ID','it-IT','ja-JP','km-KH','ko-KR','ne-NP','nl-NL','no-NO','pl-PL','pt-BR','pt-PT','ro-RO','ru-RU','si-LK','sk-SK','sv-SE','th-TH','tr-TR','uk-UA','vi-VN','zh-CN','zu-ZA'] paths: /swagger: x-swagger-pipe: swagger_raw @@ -67,11 +66,6 @@ paths: post: operationId: createUser description: Create a new temporal user in database and send an email to validate the user. - security: - - Bearer: [] - x-security-scopes: - - admin - - user parameters: - $ref: '#/parameters/User' responses: @@ -183,11 +177,6 @@ paths: post: operationId: activateUser description: Create a new user by copying it from temporal users and it removes the temporal user - security: - - Bearer: [] - x-security-scopes: - - admin - - user parameters: - in: path name: url diff --git a/test/cboard-api.postman_collection.json b/test/cboard-api.postman_collection.json index bb120fae..7702a818 100644 --- a/test/cboard-api.postman_collection.json +++ b/test/cboard-api.postman_collection.json @@ -1,7 +1,7 @@ { "variables": [], "info": { - "name": "cboard-api", + "name": "cboard-api (local)", "_postman_id": "961723c3-9f0a-ae7e-5c44-3965e8853333", "description": "", "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" @@ -17,6 +17,11 @@ "key": "Content-Type", "value": "application/json", "description": "" + }, + { + "key": "Authorization", + "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJjYm9hcmRfcm9ib3QiLCJpc3MiOiJjYm9hcmQuaW8iLCJyb2xlIjoiYWRtaW4iLCJpYXQiOjE1MTU4NzE4MzV9.C5KIQ28JinS3QJCFgnlf0ccrBunlUOMMVFr4jmfx9bw", + "description": "" } ], "body": { @@ -37,11 +42,16 @@ "key": "Content-Type", "value": "application/json", "description": "" + }, + { + "key": "Authorization", + "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJjYm9hcmRfcm9ib3QiLCJpc3MiOiJjYm9hcmQuaW8iLCJyb2xlIjoiYWRtaW4iLCJpYXQiOjE1MTU4NzE4MzV9.C5KIQ28JinS3QJCFgnlf0ccrBunlUOMMVFr4jmfx9bw", + "description": "" } ], "body": { "mode": "raw", - "raw": "{\n \"name\": \"titin2\",\n \"email\": \"martin@softwareadvice.com\",\n \"username\": \"titin2\",\n \"locale\": \"en\",\n \"password\": \"12345\"\n}" + "raw": "{\n \"name\": \"martin10\",\n \"email\": \"martinbedouret@gmail.com\",\n \"username\": \"titin10\",\n \"locale\": \"en\",\n \"password\": \"12345\"\n}" }, "description": "" }, @@ -50,13 +60,18 @@ { "name": "http://localhost:10010/user/activate/{url}", "request": { - "url": "http://localhost:10010/user/activate/123456789", + "url": "http://localhost:10010/user/activate/123456789/", "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json", "description": "" + }, + { + "key": "Authorization", + "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJjYm9hcmRfcm9ib3QiLCJpc3MiOiJjYm9hcmQuaW8iLCJyb2xlIjoiYWRtaW4iLCJpYXQiOjE1MTU4NzE4MzV9.C5KIQ28JinS3QJCFgnlf0ccrBunlUOMMVFr4jmfx9bw", + "description": "" } ], "body": { @@ -126,6 +141,51 @@ "description": "" }, "response": [] + }, + { + "name": "http://localhost:10010/user/login/{role}", + "request": { + "url": "http://localhost:10010/user/login/admin", + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "description": "" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"titint10\",\n \"email\": \"martinbedouretn@gmail.com\",\n \"username\": \"titin10\",\n \"locale\": \"en\",\n \"password\": \"12345\"\n}" + }, + "description": "" + }, + "response": [] + }, + { + "name": "http://localhost:10010/user/logout", + "request": { + "url": "http://localhost:10010/user/logout", + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "description": "" + }, + { + "key": "Authorization", + "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ0aXRpbjEwIiwiaXNzIjoiY2JvYXJkLmlvIiwicm9sZSI6ImFkbWluIiwiaWF0IjoxNTE2Mzk1NzMyfQ.6TlQv33mfUAQg0gMUyPdUOxleCi72cgBm-gDTpscAV4", + "description": "" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"martin10\",\n \"email\": \"martinbedouretn@gmail.com\",\n \"username\": \"titin10\",\n \"locale\": \"en\",\n \"password\": \"12345\"\n}" + }, + "description": "" + }, + "response": [] } ] } \ No newline at end of file From 53658f28bef23167b1d2cd607ee71b164e784e0a Mon Sep 17 00:00:00 2001 From: martin bedouret Date: Mon, 22 Jan 2018 19:30:01 -0300 Subject: [PATCH 2/2] update default lang --- api/models/User.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/models/User.js b/api/models/User.js index 4df1a7ce..4f6398a0 100644 --- a/api/models/User.js +++ b/api/models/User.js @@ -2,6 +2,7 @@ var mongoose = require('mongoose'); var bcrypt = require('bcrypt'); +var constants = require('../constants'); var Schema = mongoose.Schema; @@ -38,7 +39,7 @@ const userSchema = new Schema({ }, locale: { type: String, - default: 'en' + default: constants.DEFAULT_LANG }, password: { type: String,