From b93cc203714a84d8155ab3c9adb55eda7c6be4cb Mon Sep 17 00:00:00 2001 From: mntmn <lukas@mntmn.com> Date: Mon, 11 May 2020 14:59:37 +0200 Subject: [PATCH] users: add api_token attribute, make editable in profile/account --- models/db.js | 1 + models/migrations/02-users-add-api-token.js | 19 +++++++++++++++++++ public/javascripts/spacedeck_users.js | 1 - views/partials/account.html | 18 +++++++++++++----- 4 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 models/migrations/02-users-add-api-token.js diff --git a/models/db.js b/models/db.js index b5fb3a8..a0d2950 100644 --- a/models/db.js +++ b/models/db.js @@ -42,6 +42,7 @@ module.exports = { avatar_thumb_uri: Sequelize.STRING, confirmation_token: Sequelize.STRING, password_reset_token: Sequelize.STRING, + api_token: Sequelize.STRING, home_folder_id: Sequelize.STRING, prefs_language: Sequelize.STRING, prefs_email_notifications: Sequelize.STRING, diff --git a/models/migrations/02-users-add-api-token.js b/models/migrations/02-users-add-api-token.js new file mode 100644 index 0000000..ca8d67f --- /dev/null +++ b/models/migrations/02-users-add-api-token.js @@ -0,0 +1,19 @@ +'use strict'; + +module.exports = { + up: function(migration, DataTypes) { + return Promise.all([ + migration.addColumn('users', 'api_token', + { + type: DataTypes.STRING + } + ) + ]) + }, + + down: function(migration, DataTypes) { + return Promise.all([ + migration.removeColumn('users', 'api_token') + ]) + } +} diff --git a/public/javascripts/spacedeck_users.js b/public/javascripts/spacedeck_users.js index 7f2a9ad..3efa13a 100644 --- a/public/javascripts/spacedeck_users.js +++ b/public/javascripts/spacedeck_users.js @@ -17,7 +17,6 @@ SpacedeckUsers = { loading_user: false, password_reset_confirm_error: "", password_reset_error: "", - }, methods:{ load_user: function(on_success, on_error) { diff --git a/views/partials/account.html b/views/partials/account.html index 5f94649..450196b 100644 --- a/views/partials/account.html +++ b/views/partials/account.html @@ -55,6 +55,15 @@ </div> <div> + <div class="form-group"> + <label class="label">API Token</label> + <input + type="text" + id="api-token" + class="input input-white no-b" + v-model="user.api_token" + placeholder="secret key"> + </div> <div class="form-group"> <label class="label" >[[__("profile_name")]]</label> @@ -67,18 +76,17 @@ <div class="form-group"> <label class="label">[[__("profile_email")]]</label> - <input + type="email" id="new-email" - v-bind:class="{disabled: user.account_type=='google'}" - v-bind:disabled="user.account_type=='google'" class="input input-white no-b" - type="email" v-model="user.email" v-on:change="user.email_changed=true" placeholder="mail@example.com"> + </div> - <button class="btn btn-md btn-dark" v-on:click=" save_user()" style="margin-top:20px">Save</button> + <div class="form-group"> + <button class="btn btn-md btn-dark" v-on:click="save_user()">Save</button> </div> </div> </div> -- GitLab