FIX: fix select badge as user title on badge page (#7682)

FIX: fix select badge as user title on badge page (#7682)

diff --git a/app/assets/javascripts/discourse/components/badge-title.js.es6 b/app/assets/javascripts/discourse/components/badge-title.js.es6
index ff20079..117b1cc 100644
--- a/app/assets/javascripts/discourse/components/badge-title.js.es6
+++ b/app/assets/javascripts/discourse/components/badge-title.js.es6
@@ -13,16 +13,19 @@ export default Ember.Component.extend(BadgeSelectController, {
 
       const badge_id = this.selectedUserBadgeId || 0;
 
-      ajax(this.get("user.path") + "/preferences/badge_title", {
+      ajax(this.currentUser.path + "/preferences/badge_title", {
         type: "PUT",
         data: { user_badge_id: badge_id }
       }).then(
         () => {
           this.setProperties({
             saved: true,
-            saving: false,
-            "user.title": this.get("selectedUserBadge.badge.name")
+            saving: false
           });
+          this.currentUser.set(
+            "title",
+            this.get("selectedUserBadge.badge.name")
+          );
         },
         () => {
           bootbox.alert(I18n.t("generic_error"));
diff --git a/app/assets/javascripts/discourse/routes/badges-show.js.es6 b/app/assets/javascripts/discourse/routes/badges-show.js.es6
index 7a5b7f7..3507bea 100644
--- a/app/assets/javascripts/discourse/routes/badges-show.js.es6
+++ b/app/assets/javascripts/discourse/routes/badges-show.js.es6
@@ -30,15 +30,16 @@ export default Discourse.Route.extend({
   },
 
   afterModel(model, transition) {
-    const username =
+    const usernameFromParams =
       transition.to.queryParams && transition.to.queryParams.username;
 
     const userBadgesGrant = UserBadge.findByBadgeId(model.get("id"), {
-      username
+      username: usernameFromParams
     }).then(userBadges => {
       this.userBadgesGrant = userBadges;
     });
 
+    const username = this.currentUser && this.currentUser.username_lower;
     const userBadgesAll = UserBadge.findByUsername(username).then(
       userBadges => {
         this.userBadgesAll = userBadges;
diff --git a/app/assets/javascripts/discourse/templates/components/badge-title.hbs b/app/assets/javascripts/discourse/templates/components/badge-title.hbs
index 0ac803f..23b1f4e 100644
--- a/app/assets/javascripts/discourse/templates/components/badge-title.hbs
+++ b/app/assets/javascripts/discourse/templates/components/badge-title.hbs
@@ -8,7 +8,6 @@
     </div>
 
     <div class="control-group">
-      <label class="control-label"></label>
       <div class="controls">
         {{combo-box
           value=selectedUserBadgeId

GitHub sha: 2863e7c1

Would be nice to have a test here.

DEV: Add test (#8250)