Authentication #170

Merged
bones7242 merged 43 commits from authentication into master 2017-09-29 02:29:22 +02:00
16 changed files with 30 additions and 104 deletions
Showing only changes of commit 761aa1daf7 - Show all commits

View file

@ -1,6 +1,7 @@
kauffj commented 2017-09-22 15:38:10 +02:00 (Migrated from github.com)
Review

Great design here! Love that this makes it easy to use different channels on staging/dev and production as well as easy to change if forked.

Great design here! Love that this makes it easy to use different channels on staging/dev and production as well as easy to change if forked.
bones7242 commented 2017-09-25 17:49:10 +02:00 (Migrated from github.com)
Review

👍

:+1:
kauffj commented 2017-09-22 15:38:10 +02:00 (Migrated from github.com)
Review

Great design here! Love that this makes it easy to use different channels on staging/dev and production as well as easy to change if forked.

Great design here! Love that this makes it easy to use different channels on staging/dev and production as well as easy to change if forked.
bones7242 commented 2017-09-25 17:49:10 +02:00 (Migrated from github.com)
Review

👍

:+1:
{ {
"WalletConfig": { "WalletConfig": {
"LbryClaimAddress": "none" "LbryClaimAddress": "none",
kauffj commented 2017-09-22 15:38:10 +02:00 (Migrated from github.com)
Review

Great design here! Love that this makes it easy to use different channels on staging/dev and production as well as easy to change if forked.

Great design here! Love that this makes it easy to use different channels on staging/dev and production as well as easy to change if forked.
bones7242 commented 2017-09-25 17:49:10 +02:00 (Migrated from github.com)
Review

👍

:+1:
kauffj commented 2017-09-22 15:38:10 +02:00 (Migrated from github.com)
Review

Great design here! Love that this makes it easy to use different channels on staging/dev and production as well as easy to change if forked.

Great design here! Love that this makes it easy to use different channels on staging/dev and production as well as easy to change if forked.
bones7242 commented 2017-09-25 17:49:10 +02:00 (Migrated from github.com)
Review

👍

:+1:
"DefaultChannel": "none"
kauffj commented 2017-09-22 15:38:10 +02:00 (Migrated from github.com)
Review

Great design here! Love that this makes it easy to use different channels on staging/dev and production as well as easy to change if forked.

Great design here! Love that this makes it easy to use different channels on staging/dev and production as well as easy to change if forked.
bones7242 commented 2017-09-25 17:49:10 +02:00 (Migrated from github.com)
Review

👍

:+1:
}, },
"AnalyticsConfig":{ "AnalyticsConfig":{
"GoogleId": "none" "GoogleId": "none"
@ -11,6 +12,8 @@
kauffj commented 2017-09-22 15:38:10 +02:00 (Migrated from github.com)
Review

Great design here! Love that this makes it easy to use different channels on staging/dev and production as well as easy to change if forked.

Great design here! Love that this makes it easy to use different channels on staging/dev and production as well as easy to change if forked.
bones7242 commented 2017-09-25 17:49:10 +02:00 (Migrated from github.com)
Review

👍

:+1:
kauffj commented 2017-09-22 15:38:10 +02:00 (Migrated from github.com)
Review

Great design here! Love that this makes it easy to use different channels on staging/dev and production as well as easy to change if forked.

Great design here! Love that this makes it easy to use different channels on staging/dev and production as well as easy to change if forked.
bones7242 commented 2017-09-25 17:49:10 +02:00 (Migrated from github.com)
Review

👍

:+1:
"Password": "none" "Password": "none"
}, },
"Logging": { "Logging": {
"LogLevel": "none" "LogLevel": "none",
kauffj commented 2017-09-22 15:38:10 +02:00 (Migrated from github.com)
Review

Great design here! Love that this makes it easy to use different channels on staging/dev and production as well as easy to change if forked.

Great design here! Love that this makes it easy to use different channels on staging/dev and production as well as easy to change if forked.
bones7242 commented 2017-09-25 17:49:10 +02:00 (Migrated from github.com)
Review

👍

:+1:
kauffj commented 2017-09-22 15:38:10 +02:00 (Migrated from github.com)
Review

Great design here! Love that this makes it easy to use different channels on staging/dev and production as well as easy to change if forked.

Great design here! Love that this makes it easy to use different channels on staging/dev and production as well as easy to change if forked.
bones7242 commented 2017-09-25 17:49:10 +02:00 (Migrated from github.com)
Review

👍

:+1:
"SlackErrorChannel": "none",
kauffj commented 2017-09-22 15:38:10 +02:00 (Migrated from github.com)
Review

Great design here! Love that this makes it easy to use different channels on staging/dev and production as well as easy to change if forked.

Great design here! Love that this makes it easy to use different channels on staging/dev and production as well as easy to change if forked.
bones7242 commented 2017-09-25 17:49:10 +02:00 (Migrated from github.com)
Review

👍

:+1:
"SlackInfoChannel": "none"
kauffj commented 2017-09-22 15:38:10 +02:00 (Migrated from github.com)
Review

Great design here! Love that this makes it easy to use different channels on staging/dev and production as well as easy to change if forked.

Great design here! Love that this makes it easy to use different channels on staging/dev and production as well as easy to change if forked.
bones7242 commented 2017-09-25 17:49:10 +02:00 (Migrated from github.com)
Review

👍

:+1:
} }
} }

View file

@ -1,13 +1,10 @@
{ {
"WalletConfig": { "WalletConfig": {
"LbryClaimAddress": "none" "DefaultChannel": "@speechDev"
}, },
"AnalyticsConfig":{ "AnalyticsConfig":{
"GoogleId": "UA-100747990-1" "GoogleId": "UA-100747990-1"
}, },
"Database": {
"MySqlConnectionUri": "none"
},
"Logging": { "Logging": {
"LogLevel": "silly", "LogLevel": "silly",
"SlackErrorChannel": "#staging_speech-errors", "SlackErrorChannel": "#staging_speech-errors",

View file

@ -1,13 +1,10 @@
{ {
"WalletConfig": { "WalletConfig": {
"LbryClaimAddress": "none" "DefaultChannel": "@speech"
}, },
"AnalyticsConfig":{ "AnalyticsConfig":{
"GoogleId": "UA-60403362-3" "GoogleId": "UA-60403362-3"
}, },
"Database": {
"MySqlConnectionUri": "none"
},
"Logging": { "Logging": {
"LogLevel": "verbose", "LogLevel": "verbose",
"SlackErrorChannel": "#speech-errors", "SlackErrorChannel": "#speech-errors",

View file

@ -122,7 +122,7 @@ module.exports = {
}); });
}); });
}, },
createChannel (name) { createChannel (name, claimAddress) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios axios
.post('http://localhost:5279/lbryapi', { .post('http://localhost:5279/lbryapi', {

View file

@ -32,7 +32,7 @@ module.exports = {
throw new Error('The claim name you provided is not allowed. Only the following characters are allowed: A-Z, a-z, 0-9, and "-"'); throw new Error('The claim name you provided is not allowed. Only the following characters are allowed: A-Z, a-z, 0-9, and "-"');
} }
// validate license // validate license
if ((license.indexOf('Public Domain') === -1) && (license.indexOf('Creative Commons') === -1) && (license.indecOf('CC Attribution-NonCommercial 4.0 International') === -1)) { if ((license.indexOf('Public Domain') === -1) && (license.indexOf('Creative Commons') === -1)) {
throw new Error('Only posts with a "Public Domain" license, or one of the Creative Commons licenses are eligible for publishing through spee.ch'); throw new Error('Only posts with a "Public Domain" license, or one of the Creative Commons licenses are eligible for publishing through spee.ch');
} }
switch (nsfw) { switch (nsfw) {
@ -54,6 +54,7 @@ module.exports = {
createPublishParams (name, filePath, title, description, license, nsfw, channel) { createPublishParams (name, filePath, title, description, license, nsfw, channel) {
logger.debug(`Creating Publish Parameters for "${name}"`); logger.debug(`Creating Publish Parameters for "${name}"`);
const claimAddress = config.get('WalletConfig.LbryClaimAddress'); const claimAddress = config.get('WalletConfig.LbryClaimAddress');
const defaultChannel = config.get('WalletConfig.DefaultChannel');
// filter nsfw and ensure it is a boolean // filter nsfw and ensure it is a boolean
if (nsfw === false) { if (nsfw === false) {
nsfw = false; nsfw = false;
@ -88,10 +89,15 @@ module.exports = {
license, license,
nsfw, nsfw,
}, },
channel_name : channel,
claim_address: claimAddress, claim_address: claimAddress,
// change_address: changeAddress,
}; };
// add channel if applicable
if (channel !== 'none'){
publishParams['channel_name'] = channel;
} else {
publishParams['channel_name'] = defaultChannel;
}
logger.debug('publishParams:', publishParams); logger.debug('publishParams:', publishParams);
return publishParams; return publishParams;
}, },

View file

@ -1,20 +0,0 @@
module.exports = {
up: (queryInterface, Sequelize) => {
// logic for transforming into the new state
return queryInterface.addColumn(
'User',
'Address',
{
type : Sequelize.STRING,
allowNull: true,
}
);
},
down: (queryInterface, Sequelize) => {
// logic for reverting the changes
return queryInterface.removeColumn(
'User',
'Address'
);
},
};

View file

@ -1,7 +1,7 @@
module.exports = { module.exports = {
up: (queryInterface, Sequelize) => { up: (queryInterface, Sequelize) => {
// logic for transforming into the new state // logic for transforming into the new state
queryInterface.addColumn( return queryInterface.addColumn(
'Certificate', 'Certificate',
'UserId', 'UserId',
{ {
@ -12,7 +12,7 @@ module.exports = {
}, },
down: (queryInterface, Sequelize) => { down: (queryInterface, Sequelize) => {
// logic for reverting the changes // logic for reverting the changes
queryInterface.removeColumn( return queryInterface.removeColumn(
'Certificate', 'Certificate',
'UserId' 'UserId'
); );

View file

@ -1,34 +0,0 @@
module.exports = {
up: (queryInterface, Sequelize) => {
// logic for transforming into the new state
const p1 = queryInterface.addColumn(
'User',
'CertificateId',
{
type : Sequelize.STRING,
allowNull: true,
}
);
const p2 = queryInterface.removeColumn(
'Certificate',
'UserId'
);
return Promise.all([p1, p2]);
},
down: (queryInterface, Sequelize) => {
// logic for reverting the changes
const p1 = queryInterface.removeColumn(
'User',
'CertificateId'
);
const p2 = queryInterface.addColumn(
'Certificate',
'UserId',
{
type : Sequelize.STRING,
allowNull: true,
}
);
return Promise.all([p1, p2]);
},
};

View file

@ -1,20 +0,0 @@
module.exports = {
up: (queryInterface, Sequelize) => {
// logic for transforming into the new state
return queryInterface.removeColumn(
'User',
'Email'
);
},
down: (queryInterface, Sequelize) => {
// logic for reverting the changes
return queryInterface.addColumn(
'User',
'Email',
{
type : Sequelize.STRING,
allowNull: true,
}
);
},
};

View file

@ -14,10 +14,6 @@ module.exports = (sequelize, { STRING }) => {
type : STRING, type : STRING,
allowNull: false, allowNull: false,
}, },
address: {
type : STRING,
allowNull: false,
},
}, },
{ {
freezeTableName: true, freezeTableName: true,

View file

@ -19,21 +19,21 @@ module.exports = new PassportLocalStrategy(
// server-side validaton of inputs (username, password) // server-side validaton of inputs (username, password)
// create the channel and retrieve the metadata // create the channel and retrieve the metadata
return lbryApi.createChannel(username) return lbryApi.createChannel(username, address)
.then(tx => { .then(tx => {
// create user record // create user record
const userData = { const userData = {
channelName : username, channelName : username,
channelClaimId: tx.claim_id, channelClaimId: tx.claim_id,
password : password, password : password,
address, // address,
}; };
logger.debug('userData >', userData); logger.debug('userData >', userData);
// create certificate record // create certificate record
const certificateData = { const certificateData = {
address,
claimId: tx.claim_id, claimId: tx.claim_id,
name : username, name : username,
// address,
}; };
logger.debug('certificateData >', certificateData); logger.debug('certificateData >', certificateData);
// save user and certificate to db // save user and certificate to db

View file

@ -74,6 +74,7 @@ app.use((req, res, next) => {
res.locals.user = { res.locals.user = {
id : req.user.id, id : req.user.id,
channelName : req.user.channelName, channelName : req.user.channelName,
channelClaimId: req.user.channelClaimId,
}; };
} }
next(); next();

View file

@ -46,7 +46,7 @@
</div> </div>
<div class="panel"> <div class="panel">
<h2>Description</h2> <h2>Description</h2>
<p>{{fileInfo.description}}</> <p>{{fileInfo.description}}</p>
</div> </div>
<div class="panel"> <div class="panel">
<h2 class="subheader">Metadata</h2> <h2 class="subheader">Metadata</h2>

View file

@ -6,7 +6,7 @@
{{#if user}} {{#if user}}
<option value="{{user.channelName}}" >{{user.channelName}}</option> <option value="{{user.channelName}}" >{{user.channelName}}</option>
{{/if}} {{/if}}
<option value="@speech" >Anonymous</option> <option value="none" >None</option>
<option value="login">Login</option> <option value="login">Login</option>
<option value="new" >New</option> <option value="new" >New</option>
</select> </select>

View file

@ -6,7 +6,7 @@
<a href="/about" class="top-bar-right">help</a> <a href="/about" class="top-bar-right">help</a>
{{#if user}} {{#if user}}
<a href="/{{user.channelName}}" class="top-bar-right">{{user.channelName}}</a> <a href="/{{user.channelName}}:{{user.channelClaimId}}" class="top-bar-right">{{user.channelName}}</a>
<a href="/logout" class="top-bar-right">logout</a> <a href="/logout" class="top-bar-right">logout</a>
{{else}} {{else}}
<a href="/login" class="top-bar-right">login</a> <a href="/login" class="top-bar-right">login</a>