--- app/controllers/UserApp.java
+++ app/controllers/UserApp.java
... | ... | @@ -21,11 +21,11 @@ |
21 | 21 |
|
22 | 22 |
import com.avaje.ebean.ExpressionList; |
23 | 23 |
import com.avaje.ebean.annotation.Transactional; |
24 |
+import com.fasterxml.jackson.databind.node.ObjectNode; |
|
24 | 25 |
import controllers.annotation.AnonymousCheck; |
25 | 26 |
import models.*; |
26 | 27 |
import models.enumeration.Operation; |
27 | 28 |
import models.enumeration.UserState; |
28 |
- |
|
29 | 29 |
import org.apache.commons.lang3.ArrayUtils; |
30 | 30 |
import org.apache.commons.lang3.StringUtils; |
31 | 31 |
import org.apache.shiro.crypto.RandomNumberGenerator; |
... | ... | @@ -43,6 +43,7 @@ |
43 | 43 |
import play.mvc.Http.Cookie; |
44 | 44 |
import utils.*; |
45 | 45 |
import views.html.user.*; |
46 |
+import org.joda.time.LocalDateTime; |
|
46 | 47 |
|
47 | 48 |
import java.util.*; |
48 | 49 |
|
... | ... | @@ -579,6 +580,14 @@ |
579 | 580 |
return ok(edit_notifications.render(userForm, user)); |
580 | 581 |
case EMAILS: |
581 | 582 |
return ok(edit_emails.render(userForm, user)); |
583 |
+ case TOKEN_RESET: |
|
584 |
+ user.token = null; |
|
585 |
+ case TOKEN: |
|
586 |
+ if( StringUtils.isEmpty(user.token)){ |
|
587 |
+ user.token = new Sha256Hash(LocalDateTime.now().toString()).toBase64(); |
|
588 |
+ user.save(); |
|
589 |
+ } |
|
590 |
+ return ok(edit_token.render(userForm, user)); |
|
582 | 591 |
default: |
583 | 592 |
case PROFILE: |
584 | 593 |
return ok(edit.render(userForm, user)); |
... | ... | @@ -589,7 +598,9 @@ |
589 | 598 |
PROFILE("profile"), |
590 | 599 |
PASSWORD("password"), |
591 | 600 |
NOTIFICATIONS("notifications"), |
592 |
- EMAILS("emails"); |
|
601 |
+ EMAILS("emails"), |
|
602 |
+ TOKEN("token"), |
|
603 |
+ TOKEN_RESET("token_reset"); |
|
593 | 604 |
|
594 | 605 |
private String tabId; |
595 | 606 |
|
--- app/models/User.java
+++ app/models/User.java
... | ... | @@ -97,6 +97,7 @@ |
97 | 97 |
public String passwordSalt; |
98 | 98 |
@Constraints.Email(message = "user.wrongEmail.alert") |
99 | 99 |
public String email; |
100 |
+ public String token; |
|
100 | 101 |
|
101 | 102 |
@Transient |
102 | 103 |
private Boolean siteManager; |
+++ app/views/user/edit_token.scala.html
... | ... | @@ -0,0 +1,53 @@ |
1 | +@** | |
2 | +* Yobi, Project Hosting SW | |
3 | +* | |
4 | +* Copyright 2012 NAVER Corp. | |
5 | +* http://yobi.io | |
6 | +* | |
7 | +* @author Ahn Hyeok Jun | |
8 | +* | |
9 | +* Licensed under the Apache License, Version 2.0 (the "License"); | |
10 | +* you may not use this file except in compliance with the License. | |
11 | +* You may obtain a copy of the License at | |
12 | +* | |
13 | +* http://www.apache.org/licenses/LICENSE-2.0 | |
14 | +* | |
15 | +* Unless required by applicable law or agreed to in writing, software | |
16 | +* distributed under the License is distributed on an "AS IS" BASIS, | |
17 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
18 | +* See the License for the specific language governing permissions and | |
19 | +* limitations under the License. | |
20 | +**@ | |
21 | +@(userForm: play.data.Form[User], user:User) | |
22 | + | |
23 | +@import helper._ | |
24 | +@import utils.TemplateHelper._ | |
25 | + | |
26 | +@siteLayout(user.loginId, utils.MenuType.USER) { | |
27 | +<div class="site-breadcrumb-outer"> | |
28 | + <div class="site-breadcrumb-inner"> | |
29 | + <h3>@Messages("userinfo.token")</h3> | |
30 | + </div> | |
31 | +</div> | |
32 | +<div class="page-wrap-outer"> | |
33 | + <div class="page-wrap"> | |
34 | + @partial_edit_tabmenu("token") | |
35 | + <div class="token-generate"> | |
36 | + <form id="frmBasic" method="post" action="@routes.UserApp.editUserInfoByTabForm("token_reset")" class="pull-left" style="width:100%"> | |
37 | + <div>@Messages("userinfo.token")</div> | |
38 | + <div> | |
39 | + <input onClick="this.setSelectionRange(0, this.value.length)" size="45" style="width: 90%" type="text" name="name" class="text" value="@user.token" readonly> | |
40 | + </div> | |
41 | + <div> | |
42 | + <button type="submit" class="ybtn ybtn-success">@Messages("userinfo.recreateToken")</button> | |
43 | + </div> | |
44 | + </form> | |
45 | + </div> | |
46 | + </div> | |
47 | +</div> | |
48 | +<script type="text/javascript"> | |
49 | + $(function(){ | |
50 | + $yobi.loadModule("user.Setting"); | |
51 | + }); | |
52 | +</script> | |
53 | +} |
+++ conf/evolutions/default/6.sql
... | ... | @@ -0,0 +1,7 @@ |
1 | +# --- !Ups | |
2 | +ALTER TABLE n4user ADD COLUMN token varchar(255); | |
3 | +CREATE UNIQUE INDEX uq_n4user_token ON n4user (token); | |
4 | + | |
5 | +# --- !Downs | |
6 | +DROP INDEX IF EXISTS uq_n4user_token; | |
7 | +ALTER TABLE n4user DROP COLUMN token; |
--- conf/messages
+++ conf/messages
... | ... | @@ -965,6 +965,8 @@ |
965 | 965 |
userinfo.leaveProject.confirm = Are you sure to leave {0}? |
966 | 966 |
userinfo.profile = My profile |
967 | 967 |
userinfo.since = Member since |
968 |
+userinfo.token = User Token |
|
969 |
+userinfo.recreateToken = Recreate User Token |
|
968 | 970 |
validation.allowedCharsForLoginId = Login id may contain alphanumeric characters including dash, underscore or dot, but cannot begin or end with underscore or dot. |
969 | 971 |
validation.duplicated = Already exists! |
970 | 972 |
validation.invalidEmail = Enter valid email address! |
--- conf/messages.ko-KR
+++ conf/messages.ko-KR
... | ... | @@ -958,6 +958,8 @@ |
958 | 958 |
userinfo.leaveProject.confirm = 정말 {0} 프로젝트에서 탈퇴하시겠습니까? |
959 | 959 |
userinfo.profile = 마이 페이지 |
960 | 960 |
userinfo.since = 가입일 |
961 |
+userinfo.token = 사용자토큰 |
|
962 |
+userinfo.recreateToken = 사용자토큰 다시생성 |
|
961 | 963 |
validation.allowedCharsForLoginId = 아이디는 알파벳 숫자 - _ . 를 포함할 수 있으나 _ . 로 시작하거나 끝날 수 없습니다. |
962 | 964 |
validation.duplicated = 이미 존재합니다! |
963 | 965 |
validation.invalidEmail = 올바른 이메일을 입력해 주세요. |
--- conf/routes
+++ conf/routes
... | ... | @@ -63,6 +63,7 @@ |
63 | 63 |
POST /users/signup controllers.UserApp.newUser() |
64 | 64 |
GET /user/editform controllers.UserApp.editUserInfoForm() |
65 | 65 |
GET /user/editform/:tabId controllers.UserApp.editUserInfoByTabForm(tabId: String) |
66 |
+POST /user/editform/:tabId controllers.UserApp.editUserInfoByTabForm(tabId: String) |
|
66 | 67 |
POST /user/edit controllers.UserApp.editUserInfo() |
67 | 68 |
POST /user/resetPassword controllers.UserApp.resetUserPassword() |
68 | 69 |
GET /user/isUsed controllers.UserApp.isUsed(name:String) |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?