add support for user profiles
This commit is contained in:
parent
814f048218
commit
e0095ffaf6
@ -168,7 +168,7 @@ router.get('/raw/:id', ensureAuthenticatedWeb, function(request, response, next)
|
|||||||
router.post('/documents', ensureAuthenticatedAPI, function(request, response, next) {
|
router.post('/documents', ensureAuthenticatedAPI, function(request, response, next) {
|
||||||
return documentHandler.handlePost(request, response);
|
return documentHandler.handlePost(request, response);
|
||||||
});
|
});
|
||||||
// get documents
|
|
||||||
router.get('/documents/:id', ensureAuthenticatedAPI, function(request, response, next) {
|
router.get('/documents/:id', ensureAuthenticatedAPI, function(request, response, next) {
|
||||||
if(!request.isAuthenticated()){
|
if(!request.isAuthenticated()){
|
||||||
response.sendStatus(401);
|
response.sendStatus(401);
|
||||||
@ -181,6 +181,9 @@ router.get('/documents/:id', ensureAuthenticatedAPI, function(request, response,
|
|||||||
skipExpire
|
skipExpire
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
router.get('/users/me', ensureAuthenticatedAPI, function(req, res, next) {
|
||||||
|
return res.json(req.user);
|
||||||
|
});
|
||||||
|
|
||||||
function ensureAuthenticatedWeb(req, res, next) {
|
function ensureAuthenticatedWeb(req, res, next) {
|
||||||
if (req.isAuthenticated()) { return next(); }
|
if (req.isAuthenticated()) { return next(); }
|
||||||
|
@ -120,6 +120,10 @@ textarea {
|
|||||||
padding: 10px 15px;
|
padding: 10px 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#box4{
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
#box3 .label, #messages li {
|
#box3 .label, #messages li {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
@ -108,6 +108,10 @@ haste.prototype.setTitle = function(ext) {
|
|||||||
document.title = title;
|
document.title = title;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
haste.prototype.init = function(){
|
||||||
|
document.body.addEventListener('document.user-loaded', this.userLoaded.bind(this))
|
||||||
|
this.user.get(null)
|
||||||
|
}
|
||||||
// Show a message box
|
// Show a message box
|
||||||
haste.prototype.showMessage = function(msg, cls) {
|
haste.prototype.showMessage = function(msg, cls) {
|
||||||
var msgBox = $('<li class="'+(cls || 'info')+'">'+msg+'</li>');
|
var msgBox = $('<li class="'+(cls || 'info')+'">'+msg+'</li>');
|
||||||
@ -343,6 +347,29 @@ haste.prototype.configureButton = function(options) {
|
|||||||
$('#pointer').hide();
|
$('#pointer').hide();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
haste.prototype.user = {
|
||||||
|
get: function(id){
|
||||||
|
if(!id){
|
||||||
|
id = 'me'
|
||||||
|
}
|
||||||
|
$.ajax('/users/' + id , {
|
||||||
|
success:
|
||||||
|
function(res){
|
||||||
|
document.body.dispatchEvent(new CustomEvent('document.user-loaded', {'detail': {user: res}}))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
haste.prototype.userLoaded = function(e){
|
||||||
|
console.log(e.detail.user);
|
||||||
|
if(! (e.detail.user && e.detail.user.photos.length > 0)){
|
||||||
|
throw "error reading user photo"
|
||||||
|
}
|
||||||
|
var user = e.detail.user;
|
||||||
|
var image = user.photos[0].value;
|
||||||
|
$('#box4').append('<p><img src="' + image + '" width="50"></p>')
|
||||||
|
}
|
||||||
|
|
||||||
// Configure keyboard shortcuts for the textarea
|
// Configure keyboard shortcuts for the textarea
|
||||||
haste.prototype.configureShortcuts = function() {
|
haste.prototype.configureShortcuts = function() {
|
||||||
|
2
static/application.min.js
vendored
2
static/application.min.js
vendored
File diff suppressed because one or more lines are too long
@ -34,6 +34,9 @@
|
|||||||
app = new haste('hastebin', { twitter: true });
|
app = new haste('hastebin', { twitter: true });
|
||||||
handlePop({ target: window });
|
handlePop({ target: window });
|
||||||
});
|
});
|
||||||
|
$(document).ready(function(){
|
||||||
|
app.init();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
@ -57,6 +60,7 @@
|
|||||||
<div class="label"></div>
|
<div class="label"></div>
|
||||||
<div class="shortcut"></div>
|
<div class="shortcut"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="box4"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="linenos"></div>
|
<div id="linenos"></div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user