doortts doortts 2017-02-03
social-login: Show social login linked status icon at user profile page
@00eb71200e6974e72b5faa07959f4c581888cc16
app/assets/stylesheets/less/_page.less
--- app/assets/stylesheets/less/_page.less
+++ app/assets/stylesheets/less/_page.less
@@ -4673,6 +4673,7 @@
             font-size: 14px;
             font-weight:bold;
             color:@primary;
+            margin-left: 5px;
         }
     }
 
@@ -6652,3 +6653,9 @@
         margin-bottom: 3px;
     }
 }
+
+.providers {
+    .provider-name {
+        height: 40px;
+    }
+}
app/models/UserCredential.java
--- app/models/UserCredential.java
+++ app/models/UserCredential.java
@@ -139,4 +139,7 @@
         return LinkedAccount.findByProviderKey(this, providerKey);
     }
 
+    public static List<UserCredential> findByUserId(Long id){
+        return find.where().eq("user.id", id).findList();
+    }
 }
app/utils/TemplateHelper.scala
--- app/utils/TemplateHelper.scala
+++ app/utils/TemplateHelper.scala
@@ -34,6 +34,23 @@
       "</div>"
   }
 
+  def GithubLogo: String = {"""<span class="github"><svg aria-hidden="true" height="24" version="1.1" viewBox="0 0 16 16" width="19"><path
+  d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59 0.4 0.07 0.55-0.17 0.55-0.38 0-0.19-0.01-0.82-0.01-1.49-2.01 0.37-2.53-0.49-2.69-0.94-0.09-0.23-0.48-0.94-0.82-1.13-0.28-0.15-0.68-0.52-0.01-0.53 0.63-0.01 1.08 0.58 1.23 0.82 0.72 1.21 1.87 0.87 2.33 0.66 0.07-0.52 0.28-0.87 0.51-1.07-1.78-0.2-3.64-0.89-3.64-3.95 0-0.87 0.31-1.59 0.82-2.15-0.08-0.2-0.36-1.02 0.08-2.12 0 0 0.67-0.21 2.2 0.82 0.64-0.18 1.32-0.27 2-0.27 0.68 0 1.36 0.09 2 0.27 1.53-1.04 2.2-0.82 2.2-0.82 0.44 1.1 0.16 1.92 0.08 2.12 0.51 0.56 0.82 1.27 0.82 2.15 0 3.07-1.87 3.75-3.65 3.95 0.29 0.25 0.54 0.73 0.54 1.48 0 1.07-0.01 1.93-0.01 2.2 0 0.21 0.15 0.46 0.55 0.38C13.71 14.53 16 11.53 16 8 16 3.58 12.42 0 8 0z"></path></svg></span>"""}
+
+  def GoogleLogo: String = {
+    val url = routes.Assets.at("images/provider-logo/btn_google_light_normal_ios.svg")
+    s"""<span class="google"><img src="$url"></span>"""
+  }
+
+  def providerWithLogo(provider:String): String = {
+    val googleLogo = routes.Assets.at("images/provider-logo/btn_google_light_normal_ios.svg")
+    provider match {
+      case "github" => s"""<span class="auth-provider-logo">$GithubLogo <span class="provider-name">Sign in with Github</span></span>"""
+      case "google" => s"""<span class="auth-provider-logo"><img src="$googleLogo" alt="login with Google"> Sign in with Google</span>"""
+      case _ => ""
+    }
+  }
+
   def buildQueryString(call: Call, queryMap: Map[String, String]): String = {
     val baseUrl = call.toString
     var prefix = "?"
app/views/common/loginDialog.scala.html
--- app/views/common/loginDialog.scala.html
+++ app/views/common/loginDialog.scala.html
@@ -6,13 +6,12 @@
 **@
 @()
 @import com.feth.play.module.pa.views.html._
+@import utils.TemplateHelper._
 
 @providerWithLogo(provider:String) = @{
   val googleLogo = routes.Assets.at("images/provider-logo/btn_google_light_normal_ios.svg")
-  val githubLogo = routes.Assets.at("images/provider-logo/github.svg")
   provider match {
-    case "github" => s"""<span class="auth-provider-logo"><span class="github"><svg aria-hidden="true" height="24" version="1.1" viewBox="0 0 16 16" width="20"><path
-    d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59 0.4 0.07 0.55-0.17 0.55-0.38 0-0.19-0.01-0.82-0.01-1.49-2.01 0.37-2.53-0.49-2.69-0.94-0.09-0.23-0.48-0.94-0.82-1.13-0.28-0.15-0.68-0.52-0.01-0.53 0.63-0.01 1.08 0.58 1.23 0.82 0.72 1.21 1.87 0.87 2.33 0.66 0.07-0.52 0.28-0.87 0.51-1.07-1.78-0.2-3.64-0.89-3.64-3.95 0-0.87 0.31-1.59 0.82-2.15-0.08-0.2-0.36-1.02 0.08-2.12 0 0 0.67-0.21 2.2 0.82 0.64-0.18 1.32-0.27 2-0.27 0.68 0 1.36 0.09 2 0.27 1.53-1.04 2.2-0.82 2.2-0.82 0.44 1.1 0.16 1.92 0.08 2.12 0.51 0.56 0.82 1.27 0.82 2.15 0 3.07-1.87 3.75-3.65 3.95 0.29 0.25 0.54 0.73 0.54 1.48 0 1.07-0.01 1.93-0.01 2.2 0 0.21 0.15 0.46 0.55 0.38C13.71 14.53 16 11.53 16 8 16 3.58 12.42 0 8 0z"></path></svg></span> <span class="provider-name">Sign in with Github</span></span>"""
+    case "github" => s"""<span class="auth-provider-logo">$GithubLogo <span class="provider-name">Sign in with Github</span></span>"""
     case "google" => s"""<span class="auth-provider-logo"><img src="$googleLogo" alt="login with Google"> Sign in with Google</span>"""
     case _ => ""
   }
app/views/user/login.scala.html
--- app/views/user/login.scala.html
+++ app/views/user/login.scala.html
@@ -9,17 +9,7 @@
 @import com.feth.play.module.pa.views.html._
 @import com.feth.play.module.pa.PlayAuthenticate._;
 @import play.mvc.Http._;
-
-@providerWithLogo(provider:String) = @{
-  val googleLogo = routes.Assets.at("images/provider-logo/btn_google_light_normal_ios.svg")
-  val githubLogo = routes.Assets.at("images/provider-logo/github.svg")
-  provider match {
-    case "github" => s"""<span class="auth-provider-logo"><span class="github"><svg aria-hidden="true" height="24" version="1.1" viewBox="0 0 16 16" width="20"><path
-    d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59 0.4 0.07 0.55-0.17 0.55-0.38 0-0.19-0.01-0.82-0.01-1.49-2.01 0.37-2.53-0.49-2.69-0.94-0.09-0.23-0.48-0.94-0.82-1.13-0.28-0.15-0.68-0.52-0.01-0.53 0.63-0.01 1.08 0.58 1.23 0.82 0.72 1.21 1.87 0.87 2.33 0.66 0.07-0.52 0.28-0.87 0.51-1.07-1.78-0.2-3.64-0.89-3.64-3.95 0-0.87 0.31-1.59 0.82-2.15-0.08-0.2-0.36-1.02 0.08-2.12 0 0 0.67-0.21 2.2 0.82 0.64-0.18 1.32-0.27 2-0.27 0.68 0 1.36 0.09 2 0.27 1.53-1.04 2.2-0.82 2.2-0.82 0.44 1.1 0.16 1.92 0.08 2.12 0.51 0.56 0.82 1.27 0.82 2.15 0 3.07-1.87 3.75-3.65 3.95 0.29 0.25 0.54 0.73 0.54 1.48 0 1.07-0.01 1.93-0.01 2.2 0 0.21 0.15 0.46 0.55 0.38C13.71 14.53 16 11.53 16 8 16 3.58 12.42 0 8 0z"></path></svg></span> <span class="provider-name">Sign in with Github</span></span>"""
-    case "google" => s"""<span class="auth-provider-logo"><img src="$googleLogo" alt="login with Google"> Sign in with Google</span>"""
-    case _ => ""
-  }
-}
+@import utils.TemplateHelper._
 
 @siteLayout(message, utils.MenuType.NONE) {
 <div class="page full">
app/views/user/view.scala.html
--- app/views/user/view.scala.html
+++ app/views/user/view.scala.html
@@ -1,22 +1,8 @@
 @**
-* Yobi, Project Hosting SW
+* Yona, 21st Century Project Hosting SW
 *
-* Copyright 2012 NAVER Corp.
-* http://yobi.io
-*
-* @author Ahn Hyeok Jun
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*   http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
+* Copyright Yona & Yobi Authors & NAVER Corp.
+* https://yona.io
 **@
 @(user:User, groupNames:Array[String], projects:List[Project], postings:List[Posting], issues:List[Issue], pullRequests:List[PullRequest], milestones:List[Milestone], daysAgo:Int, selected:String)
 @import utils.MD5Util
@@ -30,6 +16,15 @@
     @Html(emailAddress.reverse.replace("@","@<span class='z'>"+MD5Util.md5Hex(emailAddress)+"</span>").replace(".", "<span class='z'>"+MD5Util.md5Hex(emailAddress).reverse+"</span>."))
 }
 @isActiveTab(tabId:String) = { @if(selected == tabId){ active } }
+
+@providerImg(provider: String) = {
+    @if(provider.equalsIgnoreCase("github")){
+        @Html(GithubLogo)
+    }
+    @if(provider.equalsIgnoreCase("google")){
+        @Html(GoogleLogo)
+    }
+}
 
 @siteLayout(user.loginId, utils.MenuType.USER) {
 <div class="site-breadcrumb-outer">
@@ -70,6 +65,19 @@
                     <strong>@Messages("userinfo.since")</strong>
                     <span class="since">@user.getDateString</span>
                 </div>
+                <div class="user-since">
+                    <div>
+                        <strong>@Messages("user.connected.social.login")</strong>
+                    </div>
+                    <div class="auth-provider-logo">
+                    @for(credential <- UserCredential.findByUserId(user.id)){
+                        @for(provider <- credential.getProviders){
+                            @providerImg(provider)
+                        }
+                    }
+                    </div>
+
+                </div>
             </div>
 
             <div class="user-stream-box">
conf/messages
--- conf/messages
+++ conf/messages
@@ -928,6 +928,7 @@
 user.avatar.uploadError = Failed to upload. Please ask site admin
 user.confirmPassword = Confirm password
 user.confirmPassword.alert = This password doesn''t match the confirmation
+user.connected.social.login = ??? ?? ???
 user.currentPassword = Current password
 user.deleted = Deleted user account
 user.email = Email address
conf/messages.ko-KR
--- conf/messages.ko-KR
+++ conf/messages.ko-KR
@@ -918,6 +918,7 @@
 user.avatar.uploadError = 아바타 이미지를 업로드 할 수 없었습니다.\n관리자에게 문의해주세요
 user.confirmPassword = 비밀번호 확인
 user.confirmPassword.alert = 입력한 두 비밀번호가 서로 일치하지 않습니다
+user.connected.social.login = 연결된 소셜 로그인
 user.currentPassword = 현재 비밀번호
 user.deleted = 삭제된 사용자 계정입니다.
 user.email = 이메일
Add a comment
List