Skip to content

Commit 0197741

Browse files
committed
dimanche
1 parent 3f5146d commit 0197741

File tree

10 files changed

+107
-21
lines changed

10 files changed

+107
-21
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ dependencies {
4747
compile "org.hibernate:hibernate-ehcache:5.1.2.Final"
4848

4949
// secu
50-
compile "org.grails.plugins:spring-security-core:3.1.1"
50+
// compile "org.grails.plugins:spring-security-core:3.1.1"
5151

5252
// feature flipping
5353
//compile "org.grails.plugins:feature-switch:0.7"

grails-app/conf/application.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ grails.plugin.springsecurity.controllerAnnotations.staticRules = [
1616
[pattern: '/profile/**', access: ['permitAll']],
1717
[pattern: '/logout/**', access: ['permitAll']],
1818
[pattern: '/comMessage/**', access: ['permitAll']],
19+
[pattern: '/myMessage/**', access: ['permitAll']],
1920
[pattern: '/answerMessage/**', access: ['permitAll']],
20-
[pattern: '/questionMessage/**', access: ['permitAll']],
21+
[pattern: '/questionMessage/**', access: ['permitAll']],
2122
[pattern: '/user/**', access: ['permitAll']],
2223
[pattern: '/index.gsp', access: ['permitAll']],
2324
[pattern: '/shutdown', access: ['permitAll']],

grails-app/controllers/ovh/garcon/tasko/AnswerMessageController.groovy

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ class AnswerMessageController {
2323

2424
static allowedMethods = [save: "POST", update: "PUT", delete: "DELETE"]
2525

26-
@Secured(['ROLE_USER', 'ROLE_ADMIN'])
26+
def show(AnswerMessage message) {
27+
respond message
28+
}
29+
30+
//@Secured(['ROLE_USER', 'ROLE_ADMIN'])
2731
@Transactional
2832
def save(AnswerMessage answerMessage) {
2933

@@ -52,12 +56,12 @@ class AnswerMessageController {
5256
}
5357
}
5458

55-
@Secured(['ROLE_USER','ROLE_ADMIN'])
59+
//@Secured(['ROLE_USER','ROLE_ADMIN'])
5660
def edit(AnswerMessage answerMessage) {
5761
respond answerMessage
5862
}
5963

60-
@Secured(['ROLE_USER', 'ROLE_ADMIN'])
64+
//@Secured(['ROLE_USER', 'ROLE_ADMIN'])
6165
@Transactional
6266
def update(AnswerMessage answerMessage) {
6367
if (answerMessage == null) {
@@ -97,7 +101,7 @@ class AnswerMessageController {
97101
* Add a new answer
98102
* @return
99103
*/
100-
@Secured(['ROLE_USER','ROLE_ADMIN'])
104+
//@Secured(['ROLE_USER','ROLE_ADMIN'])
101105
@Transactional
102106
def add(){
103107
AnswerMessage item = new AnswerMessage(

grails-app/controllers/ovh/garcon/tasko/ComMessageController.groovy

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@ class ComMessageController {
2626

2727
static allowedMethods = [save: "POST", update: "PUT", delete: "DELETE"]
2828

29+
def show(ComMessage message) {
30+
respond message
31+
}
2932

30-
@Secured(['ROLE_USER', 'ROLE_ADMIN'])
33+
//@Secured(['ROLE_USER', 'ROLE_ADMIN'])
3134
def create() {
3235
respond new ComMessage(params)
3336
}
3437

35-
@Secured(['ROLE_USER', 'ROLE_ADMIN'])
38+
//@Secured(['ROLE_USER', 'ROLE_ADMIN'])
3639
@Transactional
3740
def save(ComMessage comMessage) {
3841
if (comMessage == null) {
@@ -70,7 +73,7 @@ class ComMessageController {
7073
}
7174
}
7275

73-
@Secured(['ROLE_USER','ROLE_ADMIN'])
76+
//@Secured(['ROLE_USER','ROLE_ADMIN'])
7477
@Transactional
7578
def add(){
7679
ComMessage com = new ComMessage(

grails-app/controllers/ovh/garcon/tasko/MyMessageController.groovy

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ class MyMessageController {
2626

2727
static allowedMethods = [save: "POST", update: "PUT", delete: "DELETE"]
2828

29-
@Secured(['ROLE_USER', 'ROLE_ADMIN'])
29+
def show(MyMessage message) {
30+
respond message
31+
}
32+
33+
//@Secured(['ROLE_USER', 'ROLE_ADMIN'])
3034
@Transactional
3135
def save(MyMessage myMessage) {
3236

@@ -55,7 +59,7 @@ class MyMessageController {
5559
}
5660
}
5761

58-
@Secured(['ROLE_USER', 'ROLE_ADMIN'])
62+
//@Secured(['ROLE_USER', 'ROLE_ADMIN'])
5963
def edit(MyMessage myMessage) {
6064
respond myMessage
6165
}
@@ -91,7 +95,7 @@ class MyMessageController {
9195
* Modify the value of a message for gamification
9296
* @return
9397
*/
94-
@Secured(['ROLE_USER','ROLE_ADMIN'])
98+
//@Secured(['ROLE_USER','ROLE_ADMIN'])
9599
@Transactional
96100
def vote(){
97101
MyMessage item = MyMessage.get(params.mId as Integer)

grails-app/controllers/ovh/garcon/tasko/ProfileController.groovy

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ class ProfileController {
2020

2121
static allowedMethods = [save: "POST", update: "PUT", delete: "DELETE"]
2222

23+
def show(Profile profile) {
24+
respond profile
25+
}
26+
2327
@Transactional
2428
def save(Profile profile) {
2529
if (profile == null) {
@@ -45,7 +49,7 @@ class ProfileController {
4549
}
4650
}
4751

48-
@Secured(['ROLE_USER', 'ROLE_ADMIN'])
52+
//@Secured(['ROLE_USER', 'ROLE_ADMIN'])
4953
def edit(Profile profile) {
5054
respond profile
5155
}

grails-app/controllers/ovh/garcon/tasko/QuestionController.groovy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ class QuestionController {
3737
respond question
3838
}
3939

40-
@Secured(['ROLE_USER', 'ROLE_ADMIN'])
40+
//@Secured(['ROLE_USER', 'ROLE_ADMIN'])
4141
def create() {
4242
respond new Question(question: new QuestionMessage())
4343
}
4444

45-
@Secured(['ROLE_USER', 'ROLE_ADMIN'])
45+
//@Secured(['ROLE_USER', 'ROLE_ADMIN'])
4646
@Transactional
4747
def save(Question question) {
4848

@@ -74,7 +74,7 @@ class QuestionController {
7474
}
7575
}
7676

77-
@Secured(['ROLE_USER', 'ROLE_ADMIN'])
77+
//@Secured(['ROLE_USER', 'ROLE_ADMIN'])
7878
def edit(Question question) {
7979
respond question
8080
}
@@ -126,7 +126,7 @@ class QuestionController {
126126
}
127127
}
128128

129-
@Secured(['ROLE_USER','ROLE_ADMIN'])
129+
//@Secured(['ROLE_USER','ROLE_ADMIN'])
130130
@Transactional
131131
def solve(){
132132
Question item = Question.get(params.qId as Integer)

grails-app/controllers/ovh/garcon/tasko/QuestionMessageController.groovy

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package ovh.garcon.tasko
22

3+
import grails.web.Controller
4+
35
/**
46
* @author Benoît Garçon
57
* @date Jan-2017
@@ -12,6 +14,7 @@ import grails.transaction.Transactional
1214
* Manage message for questions
1315
*/
1416
@Transactional(readOnly = true)
17+
@Controller
1518
class QuestionMessageController {
1619

1720
static responseFormats = ['json', 'xml']
@@ -22,6 +25,10 @@ class QuestionMessageController {
2225
respond new QuestionMessage(params)
2326
}
2427

28+
def show(QuestionMessage message) {
29+
respond message
30+
}
31+
2532
@Transactional
2633
def save(QuestionMessage questionMessage) {
2734
if (questionMessage == null) {

grails-app/controllers/ovh/garcon/tasko/UserController.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class UserController {
111111
* @param user
112112
* @return
113113
*/
114-
@Secured(['ROLE_ADMIN'])
114+
//@Secured(['ROLE_ADMIN'])
115115
@Transactional
116116
def ban(User user){
117117

grails-app/init/taskoverflow/BootStrap.groovy

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class BootStrap {
1414
def returnArray = [:]
1515
returnArray['id'] = it.id
1616
returnArray['question'] = it.question
17+
returnArray['value'] = it.getValue()
1718
returnArray['title'] = it.title
1819
returnArray['isSolved'] = it.isSolved
1920
returnArray['user'] = it.user
@@ -22,10 +23,72 @@ class BootStrap {
2223
return returnArray
2324
}
2425

26+
JSON.registerObjectMarshaller(Tag) {
27+
def returnArray = [:]
28+
returnArray['id'] = it.id
29+
returnArray['label'] = it.label
30+
returnArray['questions'] = it.questions.collect{ [id: it.id, title: it.title] }
31+
32+
return returnArray
33+
}
34+
35+
JSON.registerObjectMarshaller(Badge) {
36+
def returnArray = [:]
37+
returnArray['id'] = it.id
38+
returnArray['label'] = it.label
39+
returnArray['description'] = it.description
40+
returnArray['value'] = it.value
41+
returnArray['users'] = it.users.collect{ [id: it.id, username: it.username] }
42+
43+
return returnArray
44+
}
45+
46+
JSON.registerObjectMarshaller(User) {
47+
def returnArray = [:]
48+
returnArray['id'] = it.id
49+
returnArray['accountExpired'] = it.accountExpired
50+
returnArray['accountLocked'] = it.accountLocked
51+
returnArray['enabled'] = it.enabled
52+
returnArray['messages'] = it.messages
53+
returnArray['passwordExpired'] = it.passwordExpired
54+
returnArray['profil'] = it.profil
55+
returnArray['questions'] = it.questions
56+
returnArray['username'] = it.username
57+
returnArray['badges'] = it.badges
58+
returnArray['reputation'] = it.getReputation()
59+
60+
return returnArray
61+
}
62+
63+
JSON.registerObjectMarshaller(Profile) {
64+
def returnArray = [:]
65+
returnArray['id'] = it.id
66+
returnArray['email'] = it.email
67+
returnArray['firstname'] = it.firstname
68+
returnArray['lastname'] = it.lastname
69+
returnArray['image'] = it.image
70+
returnArray['userid'] = it.user.id
71+
returnArray['username'] = it.user.username
72+
73+
return returnArray
74+
}
75+
76+
JSON.registerObjectMarshaller(MyMessage) {
77+
def returnArray = [:]
78+
returnArray['id'] = it.id
79+
returnArray['content'] = it.content
80+
returnArray['date'] = it.date.format('dd/MM/yyyy HH:mm')
81+
returnArray['userid'] = it.user.id
82+
returnArray['username'] = it.user.username
83+
returnArray['value'] = it.value
84+
85+
return returnArray
86+
}
87+
2588
//definition of badges
26-
def badgeSuperman = new Badge(label: "Superman", description: "badges.superman.desc", value: 10, users: []).save(failOnError: true)
27-
def badgeHercule = new Badge(label: "Hercule", description: "badges.hercule.desc", value: 4, users: []).save(failOnError: true)
28-
def badgeOne = new Badge(label: "N°1", description: "badges.nbone.desc", value: 4, users: []).save(failOnError: true)
89+
def badgeSuperman = new Badge(label: "Superman", description: "badges_superman_desc", value: 10, users: []).save(failOnError: true)
90+
def badgeHercule = new Badge(label: "Hercule", description: "badges_hercule_desc", value: 4, users: []).save(failOnError: true)
91+
def badgeOne = new Badge(label: "N°1", description: "badges_nbone_desc", value: 4, users: []).save(failOnError: true)
2992

3093
// security roles definition
3194
def userRole = Role.findByAuthority('ROLE_USER') ?: new Role(authority: 'ROLE_USER').save(failOnError: true)

0 commit comments

Comments
 (0)