Skip to content

Commit eece6ec

Browse files
authored
Merge pull request #392 from kaizumaki/aws-migration
サイトトップでログイン状態を取得しボタンを変更
2 parents c5de809 + 384d379 commit eece6ec

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/assets/locales/ja.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@
126126
"label": "時間割をつくる先生方",
127127
"buttons": {
128128
"signup": "ユーザー登録する",
129-
"login": "ログインする"
129+
"login": "ログインする",
130+
"registerLessons": "時間割をつくる",
131+
"logout": "ログアウトする"
130132
}
131133
}
132134
},

src/pages/index.vue

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,33 @@
3939
</v-row>
4040
<div style="margin: 0 10px">
4141
<base-action-button
42+
v-if="isLoggedIn"
43+
:text="$t('pages.index.teachers.buttons.registerLessons')"
44+
class="registerButton"
45+
@click="$router.push('/user/classlist')"
46+
/>
47+
<base-action-button
48+
v-else
4249
:text="$t('pages.index.teachers.buttons.signup')"
4350
class="registerButton"
4451
@click="$router.push('/user/terms')"
4552
/>
4653

4754
<base-action-button
55+
v-if="isLoggedIn"
56+
:text="$t('pages.index.teachers.buttons.logout')"
57+
class="loginButton"
58+
theme="secondary"
59+
@click="$router.push('/user/logout')"
60+
/>
61+
<base-action-button
62+
v-else
4863
:text="$t('pages.index.teachers.buttons.login')"
4964
class="loginButton"
5065
theme="secondary"
5166
@click="$router.push('/user/login')"
5267
/>
68+
5369
<v-footer color="#004170" padless>
5470
<ul class="Index-Footer-List">
5571
<li>
@@ -93,7 +109,7 @@
93109
import Vue from 'vue'
94110
import BaseInputField from '@/components/BaseInputField.vue'
95111
import BaseActionButton from '@/components/BaseActionButton.vue'
96-
import { API } from 'aws-amplify'
112+
import { API, Auth } from 'aws-amplify'
97113
import { GRAPHQL_AUTH_MODE, GraphQLResult } from '@aws-amplify/api'
98114
import { getClass } from '@/graphql/queries'
99115
import { GetClassQuery } from '@/API'
@@ -104,6 +120,7 @@ type DataType = {
104120
loading: boolean
105121
error: boolean
106122
valid: boolean
123+
isLoggedIn: boolean
107124
}
108125
109126
export default Vue.extend({
@@ -117,8 +134,13 @@ export default Vue.extend({
117134
loading: false,
118135
error: false,
119136
valid: true,
137+
isLoggedIn: false,
120138
}
121139
},
140+
async mounted() {
141+
const userInfo = await Auth.currentUserInfo()
142+
this.isLoggedIn = !!userInfo
143+
},
122144
methods: {
123145
async loginToClass() {
124146
this.loading = true

0 commit comments

Comments
 (0)