changed so shortChannelId is part of user creds
This commit is contained in:
parent
bf17f5a6ec
commit
a0d1cb4f5c
4 changed files with 19 additions and 23 deletions
14
speech.js
14
speech.js
|
@ -46,20 +46,23 @@ passport.serializeUser((user, done) => {
|
||||||
done(null, user.id);
|
done(null, user.id);
|
||||||
});
|
});
|
||||||
passport.deserializeUser((id, done) => { // this populates req.user
|
passport.deserializeUser((id, done) => { // this populates req.user
|
||||||
|
let userInfo = {};
|
||||||
db.User.findOne({ where: { id } })
|
db.User.findOne({ where: { id } })
|
||||||
.then(user => {
|
.then(user => {
|
||||||
user.getChannel().then(channel => {
|
|
||||||
let userInfo = {};
|
|
||||||
userInfo['id'] = user.id;
|
userInfo['id'] = user.id;
|
||||||
userInfo['userName'] = user.userName;
|
userInfo['userName'] = user.userName;
|
||||||
|
return user.getChannel();
|
||||||
|
})
|
||||||
|
.then(channel => {
|
||||||
userInfo['channelName'] = channel.channelName;
|
userInfo['channelName'] = channel.channelName;
|
||||||
userInfo['channelClaimId'] = channel.channelClaimId;
|
userInfo['channelClaimId'] = channel.channelClaimId;
|
||||||
|
return db.getShortChannelIdFromLongChannelId(channel.channelClaimId, channel.channelName);
|
||||||
|
})
|
||||||
|
.then(shortChannelId => {
|
||||||
|
userInfo['shortChannelId'] = shortChannelId;
|
||||||
done(null, userInfo);
|
done(null, userInfo);
|
||||||
});
|
|
||||||
// done(null, user);
|
|
||||||
return null;
|
return null;
|
||||||
})
|
})
|
||||||
.then()
|
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
logger.error('sequelize error', error);
|
logger.error('sequelize error', error);
|
||||||
done(error, null);
|
done(error, null);
|
||||||
|
@ -88,6 +91,7 @@ app.use((req, res, next) => {
|
||||||
userName : req.user.userName,
|
userName : req.user.userName,
|
||||||
channelName : req.user.channelName,
|
channelName : req.user.channelName,
|
||||||
channelClaimId: req.user.channelClaimId,
|
channelClaimId: req.user.channelClaimId,
|
||||||
|
shortChannelId: req.user.shortChannelId,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
next();
|
next();
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
<script src="/assets/js/generalFunctions.js"></script>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="column column--2"></div>
|
<div class="column column--2"></div>
|
||||||
<div class="column column--8">
|
<div class="column column--8">
|
||||||
|
@ -10,7 +12,6 @@
|
||||||
|
|
||||||
<script src="/socket.io/socket.io.js"></script>
|
<script src="/socket.io/socket.io.js"></script>
|
||||||
<script src="/siofu/client.js"></script>
|
<script src="/siofu/client.js"></script>
|
||||||
<script src="/assets/js/generalFunctions.js"></script>
|
|
||||||
<script src="/assets/js/validationFunctions.js"></script>
|
<script src="/assets/js/validationFunctions.js"></script>
|
||||||
<script src="/assets/js/publishFileFunctions.js"></script>
|
<script src="/assets/js/publishFileFunctions.js"></script>
|
||||||
<script typ="text/javascript">
|
<script typ="text/javascript">
|
||||||
|
|
|
@ -59,15 +59,7 @@
|
||||||
} else {
|
} else {
|
||||||
console.log('selected option:', selectedOption);
|
console.log('selected option:', selectedOption);
|
||||||
// retrieve short url from db
|
// retrieve short url from db
|
||||||
getRequest(`/api/shortChannelId/{{{user.channelClaimId}}}/{{{user.channelName}}}`)
|
urlChannel.innerText = `{{user.channelName}}:{{user.shortChannelId}}/`;
|
||||||
.then(result => {
|
|
||||||
console.log('result', result)
|
|
||||||
// update url text
|
|
||||||
urlChannel.innerText = `{{user.channelName}}:${result}/`;
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.log('error retrieving short channel id', error);
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,9 @@
|
||||||
<div class="column column--9">
|
<div class="column column--9">
|
||||||
<div id="input-error-claim-name" class="info-message info-message--failure" hidden="true"></div>
|
<div id="input-error-claim-name" class="info-message info-message--failure" hidden="true"></div>
|
||||||
<div class="input-text--primary">
|
<div class="input-text--primary">
|
||||||
<span class="url-text">Spee.ch/</span><span id="url-channel" class="url-text">{{#if user.channelName}}{{user.channelName}}/{{/if}}</span><input type="text" id="claim-name-input" class="input-text" placeholder="your-url-here" oninput="checkClaimName(event.target.value)">
|
<span class="url-text">Spee.ch/</span><span id="url-channel" class="url-text">{{#if user}}{{user.channelName}}:{{user.shortChannelId}}/{{/if}}</span><input type="text" id="claim-name-input" class="input-text" placeholder="your-url-here" oninput="checkClaimName(event.target.value)">
|
||||||
<span id="input-success-claim-name" class="info-message info-message--success"></span>
|
<span id="input-success-claim-name" class="info-message info-message--success"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue