-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from snuhcs-course/refactor/auth-clean-ver
유저 인증 관련 클래스 기능 구현 & 리팩토링
- Loading branch information
Showing
80 changed files
with
2,238 additions
and
1,108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,8 +113,7 @@ class Meta: | |
fields = ( | ||
'id', | ||
'email', | ||
'nickname', | ||
'updated_at', | ||
'nickname' | ||
) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
frontend/app/src/main/java/com/example/speechbuddy/AuthActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.example.speechbuddy | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import androidx.activity.compose.setContent | ||
import androidx.activity.viewModels | ||
import androidx.core.view.WindowCompat | ||
import com.example.speechbuddy.compose.SpeechBuddyAuth | ||
import com.example.speechbuddy.ui.SpeechBuddyTheme | ||
import com.example.speechbuddy.viewmodel.LoginViewModel | ||
import dagger.hilt.android.AndroidEntryPoint | ||
|
||
@AndroidEntryPoint | ||
class AuthActivity : BaseActivity() { | ||
|
||
private val loginViewModel: LoginViewModel by viewModels() | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
// Displaying edge-to-edge | ||
WindowCompat.setDecorFitsSystemWindows(window, false) | ||
|
||
subscribeObservers() | ||
checkPreviousAuthUser() | ||
|
||
setContent { | ||
SpeechBuddyTheme { | ||
SpeechBuddyAuth() | ||
} | ||
} | ||
} | ||
|
||
private fun subscribeObservers() { | ||
sessionManager.isAuthorized.observe(this) { isAuthorized -> | ||
if (isAuthorized) navHomeActivity() | ||
} | ||
} | ||
|
||
private fun navHomeActivity() { | ||
val intent = Intent(this, HomeActivity::class.java) | ||
startActivity(intent) | ||
finish() | ||
} | ||
|
||
private fun checkPreviousAuthUser() { | ||
loginViewModel.checkPreviousUser() | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
frontend/app/src/main/java/com/example/speechbuddy/BaseActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.example.speechbuddy | ||
|
||
import androidx.appcompat.app.AppCompatActivity | ||
import com.example.speechbuddy.domain.SessionManager | ||
import javax.inject.Inject | ||
|
||
abstract class BaseActivity : AppCompatActivity() { | ||
|
||
@Inject | ||
lateinit var sessionManager: SessionManager | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
frontend/app/src/main/java/com/example/speechbuddy/BaseApplication.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.example.speechbuddy | ||
|
||
import android.app.Application | ||
import dagger.hilt.android.HiltAndroidApp | ||
|
||
@HiltAndroidApp | ||
class BaseApplication : Application() |
27 changes: 20 additions & 7 deletions
27
...a/com/example/speechbuddy/MainActivity.kt → ...a/com/example/speechbuddy/HomeActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,41 @@ | ||
package com.example.speechbuddy | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.core.view.WindowCompat | ||
import com.example.speechbuddy.MainApplication.Companion.token_prefs | ||
import com.example.speechbuddy.compose.SpeechBuddyApp | ||
import com.example.speechbuddy.domain.utils.TokenSharedPreferences | ||
import com.example.speechbuddy.compose.SpeechBuddyHome | ||
import com.example.speechbuddy.ui.SpeechBuddyTheme | ||
import dagger.hilt.android.AndroidEntryPoint | ||
|
||
@AndroidEntryPoint | ||
class MainActivity : ComponentActivity() { | ||
class HomeActivity : BaseActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
token_prefs = TokenSharedPreferences(applicationContext) | ||
super.onCreate(savedInstanceState) | ||
|
||
// Displaying edge-to-edge | ||
WindowCompat.setDecorFitsSystemWindows(window, false) | ||
|
||
setContent { | ||
SpeechBuddyTheme { | ||
SpeechBuddyApp() | ||
SpeechBuddyHome() | ||
} | ||
} | ||
|
||
subscribeObservers() | ||
} | ||
|
||
private fun subscribeObservers() { | ||
sessionManager.isAuthorized.observe(this) { isAuthorized -> | ||
if (!isAuthorized) navAuthActivity() | ||
} | ||
} | ||
|
||
private fun navAuthActivity() { | ||
val intent = Intent(this, AuthActivity::class.java) | ||
startActivity(intent) | ||
finish() | ||
} | ||
|
||
} |
12 changes: 0 additions & 12 deletions
12
frontend/app/src/main/java/com/example/speechbuddy/MainApplication.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.