Skip to content
Snippets Groups Projects
Verified Commit b8785cf5 authored by Damien's avatar Damien
Browse files

FEAT #8805 User lang

parent 012f5f14
No related branches found
No related tags found
No related merge requests found
......@@ -226,7 +226,7 @@ CREATE TABLE users
picture text,
enabled boolean DEFAULT TRUE,
mode character varying(50) NOT NULL,
preferences jsonb NOT NULL DEFAULT '{"writingMode" : "direct", "writingSize" : 1, "writingColor" : "#000000", "notifications" : true}',
preferences jsonb NOT NULL DEFAULT '{"lang" : "fr", "writingMode" : "direct", "writingSize" : 1, "writingColor" : "#000000", "notifications" : true}',
cookie_key character varying(255) DEFAULT NULL::character varying,
cookie_date timestamp without time zone,
password_modification_date timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
......
......@@ -132,6 +132,7 @@ class UserController
}
$check = Validator::arrayType()->notEmpty()->validate($body['preferences']);
$check = $check && Validator::stringType()->notEmpty()->validate($body['preferences']['lang']) && in_array($body['preferences']['lang'], ['fr', 'en']);
$check = $check && Validator::stringType()->notEmpty()->validate($body['preferences']['writingMode']);
$check = $check && Validator::intType()->notEmpty()->validate($body['preferences']['writingSize']);
$check = $check && Validator::stringType()->notEmpty()->validate($body['preferences']['writingColor']);
......@@ -362,7 +363,7 @@ class UserController
$user['picture'] = 'data:image/png;base64,' . $user['picture'];
}
$user['preferences'] = (array)json_decode($user['preferences']);
$user['preferences'] = json_decode($user['preferences'], true);
$user['canManageRestUsers'] = UserController::hasPrivilege(['userId' => $args['id'], 'privilege' => 'manage_rest_users']);
return $user;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment