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": {
"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:
"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:
"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":{
"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"
},
"Logging": {
"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:
"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:
"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": {
"LbryClaimAddress": "none"
"DefaultChannel": "@speechDev"
},
"AnalyticsConfig":{
"GoogleId": "UA-100747990-1"
},
"Database": {
"MySqlConnectionUri": "none"
},
"Logging": {
"LogLevel": "silly",
"SlackErrorChannel": "#staging_speech-errors",

View file

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

View file

@ -122,7 +122,7 @@ module.exports = {
});
});
},
createChannel (name) {
createChannel (name, claimAddress) {
return new Promise((resolve, reject) => {
axios
.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 "-"');
}
// 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');
}
switch (nsfw) {
@ -54,6 +54,7 @@ module.exports = {
createPublishParams (name, filePath, title, description, license, nsfw, channel) {
logger.debug(`Creating Publish Parameters for "${name}"`);
const claimAddress = config.get('WalletConfig.LbryClaimAddress');
const defaultChannel = config.get('WalletConfig.DefaultChannel');
// filter nsfw and ensure it is a boolean
if (nsfw === false) {
nsfw = false;
@ -72,7 +73,7 @@ module.exports = {
if (title === '' || title === null) {
title = name;
}
if (description === '' || description === null) {
if (description === ' ' || description === null) {
description = `${name} published via spee.ch`;
}
// create the publish params
@ -88,10 +89,15 @@ module.exports = {
license,
nsfw,
},
channel_name : channel,
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);
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 = {
up: (queryInterface, Sequelize) => {
// logic for transforming into the new state
queryInterface.addColumn(
return queryInterface.addColumn(
'Certificate',
'UserId',
{
@ -12,7 +12,7 @@ module.exports = {
},
down: (queryInterface, Sequelize) => {
// logic for reverting the changes
queryInterface.removeColumn(
return queryInterface.removeColumn(
'Certificate',
'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,
allowNull: false,
},
address: {
type : STRING,
allowNull: false,
},
},
{
freezeTableName: true,

View file

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

View file

@ -72,8 +72,9 @@ app.set('view engine', 'handlebars');
app.use((req, res, next) => {
if (req.user) {
res.locals.user = {
id : req.user.id,
channelName: req.user.channelName,
id : req.user.id,
channelName : req.user.channelName,
channelClaimId: req.user.channelClaimId,
};
}
next();

View file

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

View file

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

View file

@ -6,7 +6,7 @@
<a href="/about" class="top-bar-right">help</a>
{{#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>
{{else}}
<a href="/login" class="top-bar-right">login</a>