Skip to content

Commit

Permalink
Merge pull request #28 from GDSC-snowflowerthon/feat/#27
Browse files Browse the repository at this point in the history
[Feat/#27] 둜그인 토큰 둜컬 μ €μž₯μ†Œμ— μ €μž₯
  • Loading branch information
HI-JIN2 authored Jan 12, 2024
2 parents 30662fb + 01d608e commit 9d4e6f6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class LoginActivity : AppCompatActivity() {
// μœ μ €μ˜ 아이디. ν”„λ‘œλ°”μ΄λ”μ•„μ΄λ”” λ°›μ•„μ˜΄
Log.d(TAG, "invoke: id =" + user.id)
val providerID = user.id


MySharedPreferences.setProviderId(this@LoginActivity, providerID)

val intent = Intent(this, MainActivity::class.java)
Expand All @@ -84,6 +86,8 @@ class LoginActivity : AppCompatActivity() {
override fun onResponse(call: Call<BaseResponseDto<LoginResponseDto?>>, response: retrofit2.Response<BaseResponseDto<LoginResponseDto?>>) {
if (response.isSuccessful) {
// TODO: μ„œλ²„ 응닡을 처리

MySharedPreferences.setToken(this@LoginActivity, response.body()?.data?.accessToken.toString())
Log.d("VoteFragment", response.body()?.success.toString() + response.body()?.data.toString())
Toast.makeText(this@LoginActivity, "둜그인이 μ™„λ£Œλ˜μ—ˆμ–΄μš”.", Toast.LENGTH_SHORT).show()
startActivity(intent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.snowflowerthon.snowman.ui

import android.content.Context
import android.content.SharedPreferences
import com.kakao.sdk.auth.model.OAuthToken

object MySharedPreferences {

Expand All @@ -21,6 +22,12 @@ object MySharedPreferences {
return prefs.getString("MY_PROVIDERID", "").toString()
}

fun setToken(context: Context, accessToken: String) {
val prefs: SharedPreferences = context.getSharedPreferences(MY_ACCOUNT, Context.MODE_PRIVATE)
val editor: SharedPreferences.Editor = prefs.edit()
editor.putString("MY_TOKEN", accessToken)
editor.commit()
}


}

0 comments on commit 9d4e6f6

Please sign in to comment.