mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 15:48:11 -05:00
Fix POST /db/earned_achievement to be accessible to anonymous users
This commit is contained in:
parent
956ff3300b
commit
273845ce2e
2 changed files with 4 additions and 3 deletions
|
@ -98,7 +98,7 @@ module.exports.setup = (app) ->
|
|||
app.get('/db/course_instance/:handle/course', mw.auth.checkLoggedIn(), mw.courseInstances.fetchCourse)
|
||||
|
||||
EarnedAchievement = require '../models/EarnedAchievement'
|
||||
app.post('/db/earned_achievement', mw.auth.checkLoggedIn(), mw.earnedAchievements.post)
|
||||
app.post('/db/earned_achievement', mw.auth.checkHasUser(), mw.earnedAchievements.post)
|
||||
|
||||
Level = require '../models/Level'
|
||||
app.post('/db/level/names', mw.named.names(Level))
|
||||
|
|
|
@ -172,9 +172,10 @@ describe 'POST /db/earned_achievement', ->
|
|||
eaURL = getURL('/db/earned_achievement')
|
||||
|
||||
it 'manually creates earned achievements for level achievements, which do not happen automatically', utils.wrap (done) ->
|
||||
user = yield utils.becomeAnonymous()
|
||||
session = new LevelSession({
|
||||
permissions: simplePermissions
|
||||
creator: @admin._id
|
||||
creator: user._id
|
||||
level: original: 'dungeon-arena'
|
||||
})
|
||||
yield session.save()
|
||||
|
@ -184,7 +185,7 @@ describe 'POST /db/earned_achievement', ->
|
|||
[res, body] = yield request.postAsync { url: eaURL, json }
|
||||
expect(res.statusCode).toBe(201)
|
||||
expect(body.achievement).toBe @unlockable.id
|
||||
expect(body.user).toBe @admin.id
|
||||
expect(body.user).toBe user.id
|
||||
expect(body.notified).toBeFalsy()
|
||||
expect(body.earnedPoints).toBe unlockable.worth
|
||||
expect(body.achievedAmount).toBeUndefined()
|
||||
|
|
Loading…
Reference in a new issue