Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions api/constants/index.js
Original file line number Diff line number Diff line change
@@ -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
};
3 changes: 2 additions & 1 deletion api/models/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

var mongoose = require('mongoose');
var bcrypt = require('bcrypt');
var constants = require('../constants');


var Schema = mongoose.Schema;
Expand Down Expand Up @@ -38,7 +39,7 @@ const userSchema = new Schema({
},
locale: {
type: String,
default: 'en'
default: constants.DEFAULT_LANG
},
password: {
type: String,
Expand Down
13 changes: 1 addition & 12 deletions api/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down
66 changes: 63 additions & 3 deletions test/cboard-api.postman_collection.json
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -17,6 +17,11 @@
"key": "Content-Type",
"value": "application/json",
"description": ""
},
{
"key": "Authorization",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJjYm9hcmRfcm9ib3QiLCJpc3MiOiJjYm9hcmQuaW8iLCJyb2xlIjoiYWRtaW4iLCJpYXQiOjE1MTU4NzE4MzV9.C5KIQ28JinS3QJCFgnlf0ccrBunlUOMMVFr4jmfx9bw",
"description": ""
}
],
"body": {
Expand All @@ -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": ""
},
Expand All @@ -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": {
Expand Down Expand Up @@ -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\": \"[email protected]\",\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\": \"[email protected]\",\n \"username\": \"titin10\",\n \"locale\": \"en\",\n \"password\": \"12345\"\n}"
},
"description": ""
},
"response": []
}
]
}