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
24
speech.js
24
speech.js
|
@ -46,20 +46,23 @@ passport.serializeUser((user, done) => {
|
|||
done(null, user.id);
|
||||
});
|
||||
passport.deserializeUser((id, done) => { // this populates req.user
|
||||
let userInfo = {};
|
||||
db.User.findOne({ where: { id } })
|
||||
.then(user => {
|
||||
user.getChannel().then(channel => {
|
||||
let userInfo = {};
|
||||
userInfo['id'] = user.id;
|
||||
userInfo['userName'] = user.userName;
|
||||
userInfo['channelName'] = channel.channelName;
|
||||
userInfo['channelClaimId'] = channel.channelClaimId;
|
||||
done(null, userInfo);
|
||||
});
|
||||
// done(null, user);
|
||||
userInfo['id'] = user.id;
|
||||
userInfo['userName'] = user.userName;
|
||||
return user.getChannel();
|
||||
})
|
||||
.then(channel => {
|
||||
userInfo['channelName'] = channel.channelName;
|
||||
userInfo['channelClaimId'] = channel.channelClaimId;
|
||||
return db.getShortChannelIdFromLongChannelId(channel.channelClaimId, channel.channelName);
|
||||
})
|
||||
.then(shortChannelId => {
|
||||
userInfo['shortChannelId'] = shortChannelId;
|
||||
done(null, userInfo);
|
||||
return null;
|
||||
})
|
||||
.then()
|
||||
.catch(error => {
|
||||
logger.error('sequelize error', error);
|
||||
done(error, null);
|
||||
|
@ -88,6 +91,7 @@ app.use((req, res, next) => {
|
|||
userName : req.user.userName,
|
||||
channelName : req.user.channelName,
|
||||
channelClaimId: req.user.channelClaimId,
|
||||
shortChannelId: req.user.shortChannelId,
|
||||
};
|
||||
}
|
||||
next();
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
<script src="/assets/js/generalFunctions.js"></script>
|
||||
|
||||
<div class="row">
|
||||
<div class="column column--2"></div>
|
||||
<div class="column column--8">
|
||||
|
@ -10,7 +12,6 @@
|
|||
|
||||
<script src="/socket.io/socket.io.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/publishFileFunctions.js"></script>
|
||||
<script typ="text/javascript">
|
||||
|
|
|
@ -59,15 +59,7 @@
|
|||
} else {
|
||||
console.log('selected option:', selectedOption);
|
||||
// retrieve short url from db
|
||||
getRequest(`/api/shortChannelId/{{{user.channelClaimId}}}/{{{user.channelName}}}`)
|
||||
.then(result => {
|
||||
console.log('result', result)
|
||||
// update url text
|
||||
urlChannel.innerText = `{{user.channelName}}:${result}/`;
|
||||
})
|
||||
.catch(error => {
|
||||
console.log('error retrieving short channel id', error);
|
||||
})
|
||||
urlChannel.innerText = `{{user.channelName}}:{{user.shortChannelId}}/`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,10 +5,9 @@
|
|||
<div class="column column--9">
|
||||
<div id="input-error-claim-name" class="info-message info-message--failure" hidden="true"></div>
|
||||
<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>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
Loading…
Reference in a new issue