diff --git a/assets/style.less b/assets/style.less
index 150a3876..205b410e 100644
--- a/assets/style.less
+++ b/assets/style.less
@@ -25,10 +25,14 @@ html, body {
// }
.el-card {
- max-width: 670px;
+ max-width: 630px;
margin: 30px auto;
}
+#admin.el-card {
+ max-width: 850px;
+}
+
.el-dialog {
margin-top: 0px !important;
border-radius: 0px;
diff --git a/components/admin/Users.vue b/components/admin/Users.vue
index 9416cabb..72b2c8ca 100644
--- a/components/admin/Users.vue
+++ b/components/admin/Users.vue
@@ -6,6 +6,8 @@ div
template(slot='title')
h4 {{$t('common.new_user')}}
el-form(inline)
+ el-form-item(:label="$t('common.username')")
+ el-input(v-model='new_user.username')
el-form-item(:label="$t('common.email')")
el-input(v-model='new_user.email')
el-form-item(:label="$t('common.admin')")
@@ -14,23 +16,26 @@ div
//- USERS LIST
el-table(:data='paginatedUsers' small)
+ el-table-column(label='Username')
+ template(slot-scope='data')
+ span(slot='reference') {{data.row.username}}
el-table-column(label='Email')
template(slot-scope='data')
el-popover(trigger='hover' :content='data.row.description' width='400')
span(slot='reference') {{data.row.email}}
-
el-table-column(:label="$t('common.actions')")
template(slot-scope='data')
div(v-if='data.row.id!==$auth.user.id')
- el-button.mr-1(size='mini'
- :type='data.row.is_active?"warning":"success"'
- @click='toggle(data.row)') {{data.row.is_active?$t('common.deactivate'):$t('common.activate')}}
- el-button(size='mini'
- :type='data.row.is_admin?"danger":"warning"'
- @click='toggleAdmin(data.row)') {{data.row.is_admin?$t('admin.remove_admin'):$t('common.admin')}}
- el-button(size='mini'
- type='danger'
- @click='delete_user(data.row)') {{$t('admin.delete_user')}}
+ el-button-group
+ el-button(size='mini'
+ :type='data.row.is_active?"warning":"success"'
+ @click='toggle(data.row)') {{data.row.is_active?$t('common.deactivate'):$t('common.activate')}}
+ el-button(size='mini'
+ :type='data.row.is_admin?"danger":"warning"'
+ @click='toggleAdmin(data.row)') {{data.row.is_admin?$t('admin.remove_admin'):$t('common.admin')}}
+ el-button(size='mini'
+ type='danger'
+ @click='delete_user(data.row)') {{$t('admin.delete_user')}}
div(v-else)
span {{$t('common.me')}}
diff --git a/locales/it.js b/locales/it.js
index effc2eb6..a63fd5eb 100644
--- a/locales/it.js
+++ b/locales/it.js
@@ -48,7 +48,8 @@ export default {
enable: 'Abilita',
disable: 'Disabilita',
me: 'Sei te',
- password_updated: 'Password modificata!'
+ password_updated: 'Password modificata!',
+ username: 'Nickname'
},
login: {
diff --git a/pages/admin.vue b/pages/admin.vue
index 5039d3cd..2713a9b1 100644
--- a/pages/admin.vue
+++ b/pages/admin.vue
@@ -1,5 +1,5 @@
- el-card
+ el-card#admin
nuxt-link.float-right(to='/')
v-icon(name='times' color='red')
h5 {{$t('common.admin')}}
diff --git a/server/api/models/user.js b/server/api/models/user.js
index cb2e8bd0..5a050140 100644
--- a/server/api/models/user.js
+++ b/server/api/models/user.js
@@ -1,5 +1,9 @@
'use strict'
const bcrypt = require('bcryptjs')
+const crypto = require('crypto')
+const util = require('util')
+
+const generateKeyPair = util.promisify(crypto.generateKeyPair)
module.exports = (sequelize, DataTypes) => {
const user = sequelize.define('user', {
@@ -20,7 +24,8 @@ module.exports = (sequelize, DataTypes) => {
password: DataTypes.STRING,
recover_code: DataTypes.STRING,
is_admin: DataTypes.BOOLEAN,
- is_active: DataTypes.BOOLEAN
+ is_active: DataTypes.BOOLEAN,
+ rsa: DataTypes.JSONB
}, {
scopes: {
withoutPassword: {
@@ -48,5 +53,22 @@ module.exports = (sequelize, DataTypes) => {
}
})
+ user.beforeCreate(async (user, options) => {
+ // generate rsa keys
+ console.error('generate rsa key')
+ const rsa = await generateKeyPair('rsa', {
+ modulusLength: 4096,
+ publicKeyEncoding: {
+ type: 'spki',
+ format: 'pem'
+ },
+ privateKeyEncoding: {
+ type: 'pkcs8',
+ format: 'pem'
+ }
+ })
+ user.rsa = rsa
+ })
+
return user
};
diff --git a/server/federation/index.js b/server/federation/index.js
index 4b112c6e..f4225190 100644
--- a/server/federation/index.js
+++ b/server/federation/index.js
@@ -8,7 +8,6 @@ router.get('/u/:name', async (req, res) => {
if (!name) return res.status(400).send('Bad request.')
const user = await User.findOne({where: { username: name }})
if (!user) return res.status(404).send(`No record found for ${name}`)
- const domain = 'local'
const ret = {
'@context': [
'https://www.w3.org/ns/activitystreams',
@@ -22,7 +21,7 @@ router.get('/u/:name', async (req, res) => {
'publicKey': {
'id': `${config.baseurl}/federation/u/${name}#main-key`,
'owner': `${config.baseurl}/federation/u/${name}`,
- 'publicKeyPem': user.pubkey
+ 'publicKeyPem': user.rsa.publicKey
}
}
res.json(ret)
diff --git a/server/migrations/20190729103119-add_rsa.js b/server/migrations/20190729103119-add_rsa.js
new file mode 100644
index 00000000..97bdbac3
--- /dev/null
+++ b/server/migrations/20190729103119-add_rsa.js
@@ -0,0 +1,26 @@
+'use strict';
+
+module.exports = {
+ up: (queryInterface, Sequelize) => {
+ return queryInterface.addColumn('users', 'rsa', {
+ type: Sequelize.JSONB
+ })
+ /*
+ Add altering commands here.
+ Return a promise to correctly handle asynchronicity.
+
+ Example:
+ return queryInterface.createTable('users', { id: Sequelize.INTEGER });
+ */
+ },
+
+ down: (queryInterface, Sequelize) => {
+ /*
+ Add reverting commands here.
+ Return a promise to correctly handle asynchronicity.
+
+ Example:
+ return queryInterface.dropTable('users');
+ */
+ }
+};