fix unauthenticated challenge bug and hide pair, bug and help buttons when unauthenticated
This commit is contained in:
@ -175,6 +175,7 @@ exports.returnIndividualChallenge = function(req, res, next) {
|
|||||||
if (dashedNameFull !== dashedName) {
|
if (dashedNameFull !== dashedName) {
|
||||||
return res.redirect('../challenges/' + dashedNameFull);
|
return res.redirect('../challenges/' + dashedNameFull);
|
||||||
} else {
|
} else {
|
||||||
|
if (req.user) {
|
||||||
req.user.currentChallenge = {
|
req.user.currentChallenge = {
|
||||||
challengeId: challenge._id,
|
challengeId: challenge._id,
|
||||||
challengeName: challenge.name,
|
challengeName: challenge.name,
|
||||||
@ -190,6 +191,7 @@ exports.returnIndividualChallenge = function(req, res, next) {
|
|||||||
))
|
))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var challengeType = {
|
var challengeType = {
|
||||||
0: function() {
|
0: function() {
|
||||||
@ -295,12 +297,16 @@ exports.returnIndividualChallenge = function(req, res, next) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
if (req.user) {
|
||||||
req.user.save(function (err) {
|
req.user.save(function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
return challengeType[challenge.challengeType]();
|
return challengeType[challenge.challengeType]();
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
return challengeType[challenge.challengeType]();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -91,6 +91,7 @@ block content
|
|||||||
span.ion-close-circled
|
span.ion-close-circled
|
||||||
| Username not found
|
| Username not found
|
||||||
#submitButton.btn.btn-primary.btn-big.btn-block Run code (ctrl + enter)
|
#submitButton.btn.btn-primary.btn-big.btn-block Run code (ctrl + enter)
|
||||||
|
if (user)
|
||||||
.button-spacer
|
.button-spacer
|
||||||
.btn-group.input-group.btn-group-justified
|
.btn-group.input-group.btn-group-justified
|
||||||
label.btn.btn-success#i-want-help
|
label.btn.btn-success#i-want-help
|
||||||
|
@ -37,8 +37,8 @@ block content
|
|||||||
#less-info.btn.btn-primary.btn-block.btn-primary-ghost
|
#less-info.btn.btn-primary.btn-block.btn-primary-ghost
|
||||||
span.ion-arrow-up-b
|
span.ion-arrow-up-b
|
||||||
| Less information
|
| Less information
|
||||||
br
|
|
||||||
- if (user)
|
- if (user)
|
||||||
|
br
|
||||||
a.btn.btn-primary.btn-big.btn-block#next-courseware-button
|
a.btn.btn-primary.btn-big.btn-block#next-courseware-button
|
||||||
| Go to my next challenge
|
| Go to my next challenge
|
||||||
br
|
br
|
||||||
|
@ -36,6 +36,7 @@ block content
|
|||||||
| Less information
|
| Less information
|
||||||
#submitButton.btn.btn-primary.btn-big.btn-block Run code (ctrl + enter)
|
#submitButton.btn.btn-primary.btn-big.btn-block Run code (ctrl + enter)
|
||||||
.button-spacer
|
.button-spacer
|
||||||
|
if (user)
|
||||||
.btn-group.input-group.btn-group-justified
|
.btn-group.input-group.btn-group-justified
|
||||||
label.btn.btn-success#i-want-help
|
label.btn.btn-success#i-want-help
|
||||||
i.fa.fa-medkit
|
i.fa.fa-medkit
|
||||||
@ -46,7 +47,7 @@ block content
|
|||||||
label.btn.btn-success#report-issue
|
label.btn.btn-success#report-issue
|
||||||
i.fa.fa-bug
|
i.fa.fa-bug
|
||||||
| Bug
|
| Bug
|
||||||
br
|
.spacer
|
||||||
form.code
|
form.code
|
||||||
.form-group.codeMirrorView
|
.form-group.codeMirrorView
|
||||||
textarea#codeOutput(style='display: none;')
|
textarea#codeOutput(style='display: none;')
|
||||||
|
@ -21,11 +21,6 @@ block content
|
|||||||
a.btn.btn-primary.btn-big.btn-block#completed-courseware I've completed this challenge (ctrl + enter)
|
a.btn.btn-primary.btn-big.btn-block#completed-courseware I've completed this challenge (ctrl + enter)
|
||||||
script.
|
script.
|
||||||
var userLoggedIn = true;
|
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
|
.button-spacer
|
||||||
.btn-group.input-group.btn-group-justified
|
.btn-group.input-group.btn-group-justified
|
||||||
.btn.btn-success.btn-big#i-want-help-editorless
|
.btn.btn-success.btn-big#i-want-help-editorless
|
||||||
@ -35,6 +30,12 @@ block content
|
|||||||
i.fa.fa-bug
|
i.fa.fa-bug
|
||||||
| Report a bug
|
| Report a bug
|
||||||
.button-spacer
|
.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").
|
script(type="text/javascript").
|
||||||
|
|
||||||
var controlEnterHandler = function(e) {
|
var controlEnterHandler = function(e) {
|
||||||
|
Reference in New Issue
Block a user