fix unauthenticated challenge bug and hide pair, bug and help buttons when unauthenticated

This commit is contained in:
Quincy Larson
2015-05-25 18:00:45 -07:00
parent 95ab51986e
commit 08837304fd
5 changed files with 60 additions and 51 deletions

View File

@ -175,6 +175,7 @@ exports.returnIndividualChallenge = function(req, res, next) {
if (dashedNameFull !== dashedName) {
return res.redirect('../challenges/' + dashedNameFull);
} else {
if (req.user) {
req.user.currentChallenge = {
challengeId: challenge._id,
challengeName: challenge.name,
@ -190,6 +191,7 @@ exports.returnIndividualChallenge = function(req, res, next) {
))
};
}
}
var challengeType = {
0: function() {
@ -295,12 +297,16 @@ exports.returnIndividualChallenge = function(req, res, next) {
});
}
};
if (req.user) {
req.user.save(function (err) {
if (err) {
return next(err);
}
return challengeType[challenge.challengeType]();
});
} else {
return challengeType[challenge.challengeType]();
}
});
};

View File

@ -91,6 +91,7 @@ block content
span.ion-close-circled
| Username not found
#submitButton.btn.btn-primary.btn-big.btn-block Run code (ctrl + enter)
if (user)
.button-spacer
.btn-group.input-group.btn-group-justified
label.btn.btn-success#i-want-help

View File

@ -37,8 +37,8 @@ block content
#less-info.btn.btn-primary.btn-block.btn-primary-ghost
span.ion-arrow-up-b
| Less information
br
- if (user)
br
a.btn.btn-primary.btn-big.btn-block#next-courseware-button
| Go to my next challenge
br

View File

@ -36,6 +36,7 @@ block content
| Less information
#submitButton.btn.btn-primary.btn-big.btn-block Run code (ctrl + enter)
.button-spacer
if (user)
.btn-group.input-group.btn-group-justified
label.btn.btn-success#i-want-help
i.fa.fa-medkit
@ -46,7 +47,7 @@ block content
label.btn.btn-success#report-issue
i.fa.fa-bug
|   Bug
br
.spacer
form.code
.form-group.codeMirrorView
textarea#codeOutput(style='display: none;')

View File

@ -21,11 +21,6 @@ block content
a.btn.btn-primary.btn-big.btn-block#completed-courseware I've completed this challenge (ctrl + enter)
script.
var userLoggedIn = true;
- else
a.btn.btn-big.signup-btn.btn-block(href='/login') Sign in so you can save your progress
script.
var userLoggedIn = false;
br
.button-spacer
.btn-group.input-group.btn-group-justified
.btn.btn-success.btn-big#i-want-help-editorless
@ -35,6 +30,12 @@ block content
i.fa.fa-bug
|   Report a bug
.button-spacer
- else
a.btn.btn-big.signup-btn.btn-block(href='/login') Sign in so you can save your progress
script.
var userLoggedIn = false;
br
script(type="text/javascript").
var controlEnterHandler = function(e) {