Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit06be1fb

Browse files
committed
Added some default claims to the jwt token. Added Sign in component. Fixed small layout issues on small display
1 parent75efe1b commit06be1fb

File tree

5 files changed

+67
-37
lines changed

5 files changed

+67
-37
lines changed

‎frontend/client/components/layout/AppMain.vue‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ export default {
3737
@import'~bulma/sass/utilities/mixins';
3838
3939
.app-main {
40-
padding-top:90px;
41-
margin-left:270px;
40+
padding-top:0px;
41+
margin-left:220px;
4242
4343
@includemobile() {
4444
margin-left:0;

‎frontend/client/components/layout/Navbar.vue‎

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
</div>
1313
<divclass="navbar-end">
1414
<aclass="navbar-item"v-if="session === null"v-on:click="showLoginModal">
15-
<spanclass="has-text-white">Login</span>
15+
<iclass="fa fa-sign-in fa-2x sign-in-icon"aria-hidden="true"/>
16+
<spanclass="sign-in-text">Sign in</span>
1617
</a>
1718
<spanclass="has-text-white"v-if="session">{{ session.display_name }}</span>
1819
</div>
@@ -21,22 +22,26 @@
2122

2223
<!-- Login modal-->
2324
<modal:visible="loginModal"class="modal-z-index"@close="close">
24-
<divclass="tile is-parent is-4">
25-
<articleclass="tile is-child box">
26-
<h1class="title">Sign In</h1>
27-
<divclass="block">
28-
<pclass="control">
29-
<inputclass="input is-large"type="text"v-model="username"placeholder="Username">
30-
</p>
31-
<pclass="control">
32-
<inputclass="input is-large"type="password"v-model="password"placeholder="Password">
33-
</p>
34-
<pclass="control">
35-
<buttonclass="button is-primary"@click="login">Sign In</button>
36-
</p>
37-
</div>
38-
</article>
39-
</div>
25+
<articleclass="tile is-child box">
26+
<h1class="title">Sign In</h1>
27+
<divclass="block">
28+
<pclass="control has-icons-left">
29+
<inputclass="input is-large"type="text"v-model="username"placeholder="Username">
30+
<spanclass="icon is-small is-left">
31+
<iclass="fa fa-user-circle"></i>
32+
</span>
33+
</p>
34+
<pclass="control has-icons-left">
35+
<inputclass="input is-large"type="password"v-model="password"placeholder="Password">
36+
<spanclass="icon is-small is-left">
37+
<iclass="fa fa-lock"></i>
38+
</span>
39+
</p>
40+
<pclass="control">
41+
<buttonclass="button is-primary"@click="login">Sign In</button>
42+
</p>
43+
</div>
44+
</article>
4045
</modal>
4146
</section>
4247
</template>
@@ -116,7 +121,7 @@ export default {
116121
<style lang="scss">
117122
118123
.navbar-start {
119-
padding-left:280px;
124+
padding-left:240px;
120125
}
121126
122127
.search-icon {
@@ -149,7 +154,7 @@ export default {
149154
}
150155
151156
.app-navbar {
152-
position:fixed;
157+
position:static;
153158
min-width:100%;
154159
height:70px;
155160
z-index:1024-1;
@@ -164,4 +169,17 @@ export default {
164169
.modal-z-index {
165170
z-index:1025;
166171
}
172+
173+
.sign-in-text {
174+
font-size:20px;
175+
font-weight:bold;
176+
color:whitesmoke;
177+
padding-top:7px;
178+
}
179+
180+
.sign-in-icon {
181+
color:#4da2fc;
182+
padding-right:15px;
183+
padding-top:7px;
184+
}
167185
</style>

‎frontend/client/components/layout/Sidebar.vue‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<asideclass="menu app-sidebar animated":class="{ slideInLeft: show, slideOutLeft: !show }">
3-
<divclass="">
3+
<div>
44
<aclass="navbar-item brand-top"href="/">
55
<imgsrc="~assets/logo.png">
66
&nbsp;&nbsp;<divclass="header-text">Gaia</div>
@@ -153,7 +153,7 @@ a.navbar-item:hover {
153153
top:0px;
154154
left:0;
155155
padding:0px0px50px;
156-
width:240px;
156+
width:200px;
157157
min-width:175px;
158158
max-height:100vh;
159159
height:100%;
@@ -179,20 +179,20 @@ a.navbar-item:hover {
179179
180180
.brand-top {
181181
margin:auto;
182-
width:240px;
183-
padding-left:60px;
184-
padding-bottom:50px;
182+
width:200px;
183+
padding-left:45px;
184+
padding-bottom:40px;
185185
}
186186
187187
.icon-left {
188188
position:absolute;
189-
left:40px;
189+
left:20px;
190190
margin-top:13px;
191191
}
192192
193193
.menu-list {
194194
margin:auto;
195-
width:220px;
195+
width:200px;
196196
197197
li {
198198
float:left;
@@ -211,7 +211,7 @@ a.navbar-item:hover {
211211
212212
lia {
213213
color:#8c91a0;
214-
width:180px;
214+
width:140px;
215215
margin-left:60px;
216216
line-height:40px;
217217

‎gaia.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package gaia
33
// User is the user object
44
typeUserstruct {
55
Usernamestring`json:"username"`
6-
Passwordstring`json:"password"`
6+
Passwordstring`json:"password,omitempty"`
77
DisplayNamestring`json:"display_name"`
88
Tokenstringstring`json:"tokenstring"`
99
}

‎handlers/User.go‎

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@ package handlers
22

33
import (
44
"fmt"
5+
"time"
56

67
jwt"github.com/dgrijalva/jwt-go"
78
"github.com/kataras/iris"
89
"github.com/michelvocks/gaia"
910
)
1011

12+
typejwtCustomClaimsstruct {
13+
Usernamestring`json:"username"`
14+
jwt.StandardClaims
15+
}
16+
1117
// UserLogin authenticates the user with
1218
// the given credentials.
1319
funcUserLogin(ctx iris.Context) {
@@ -24,10 +30,19 @@ func UserLogin(ctx iris.Context) {
2430
// Remove password from object
2531
u.Password=""
2632

27-
// Wrap User object in JWT
28-
token:=jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{
29-
"username":u.Username,
30-
})
33+
// Setup custom claims
34+
claims:=jwtCustomClaims{
35+
u.Username,
36+
jwt.StandardClaims{
37+
// Valid for 5 hours
38+
ExpiresAt:time.Now().Unix()+ (5*60*60),
39+
IssuedAt:time.Now().Unix(),
40+
Subject:"Gaia Session Token",
41+
},
42+
}
43+
44+
// Generate JWT token
45+
token:=jwt.NewWithClaims(jwt.SigningMethodHS256,claims)
3146

3247
// Sign and get encoded token
3348
b:= []byte{'f','2','f','f','s','h','s'}
@@ -43,7 +58,4 @@ func UserLogin(ctx iris.Context) {
4358

4459
// Return JWT token and display name
4560
ctx.JSON(u)
46-
47-
fmt.Println("Token returned!")
48-
fmt.Printf("User obj: %+v\n",u)
4961
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp