Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
J
JWT
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kis_intern1
JWT
Commits
80baba42
Commit
80baba42
authored
Aug 10, 2023
by
nk161690
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Custom authen
parent
64836641
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
2485 additions
and
12 deletions
+2485
-12
UnityProject/Assets/AccountLogin.cs
UnityProject/Assets/AccountLogin.cs
+91
-0
UnityProject/Assets/AccountLogin.cs.meta
UnityProject/Assets/AccountLogin.cs.meta
+11
-0
UnityProject/Assets/FacebookLogin.cs
UnityProject/Assets/FacebookLogin.cs
+0
-6
UnityProject/Assets/GoogleLogin.cs
UnityProject/Assets/GoogleLogin.cs
+0
-2
UnityProject/Assets/Scenes/Login.unity
UnityProject/Assets/Scenes/Login.unity
+2153
-0
UnityProject/Assets/Scenes/Login.unity.meta
UnityProject/Assets/Scenes/Login.unity.meta
+0
-0
UnityProject/Assets/Scenes/Main.unity
UnityProject/Assets/Scenes/Main.unity
+222
-0
UnityProject/Assets/Scenes/Main.unity.meta
UnityProject/Assets/Scenes/Main.unity.meta
+7
-0
UnityProject/Assets/UserSessionManager.cs
UnityProject/Assets/UserSessionManager.cs
+0
-3
UnityProject/ProjectSettings/EditorBuildSettings.asset
UnityProject/ProjectSettings/EditorBuildSettings.asset
+1
-1
No files found.
UnityProject/Assets/AccountLogin.cs
0 → 100644
View file @
80baba42
using
Newtonsoft.Json
;
using
Photon.Pun
;
using
Photon.Realtime
;
using
System.Collections
;
using
System.Collections.Generic
;
using
System.Net.Http
;
using
TMPro
;
using
UnityEngine
;
public
class
AccountLogin
:
MonoBehaviour
{
[
SerializeField
]
private
TextMeshProUGUI
username
;
[
SerializeField
]
private
TextMeshProUGUI
password
;
[
SerializeField
]
private
TextMeshProUGUI
message
;
private
readonly
string
baseURL
=
"http://localhost:5172/User/"
;
public
class
RespondMessage
{
public
bool
Success
{
get
;
set
;
}
public
string
Message
{
get
;
set
;
}
public
string
Data
{
get
;
set
;
}
}
public
async
void
CallLoginAPI
()
{
string
endpoint
=
"Login"
;
string
email
=
CleanInput
(
username
.
text
.
Trim
());
string
pwd
=
CleanInput
(
password
.
text
.
Trim
());
using
(
HttpClient
client
=
new
HttpClient
())
{
string
apiUrl
=
$"
{
baseURL
}{
endpoint
}
?email=
{
email
}
&pwd=
{
pwd
}
"
;
using
(
HttpResponseMessage
res
=
await
client
.
GetAsync
(
apiUrl
))
{
using
(
HttpContent
content
=
res
.
Content
)
{
string
data
=
await
content
.
ReadAsStringAsync
();
RespondMessage
respondMessage
=
JsonConvert
.
DeserializeObject
<
RespondMessage
>(
data
);
if
(
respondMessage
.
Success
)
{
//AuthenticateWithPhoton("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9
//.eyJlbWFpbCI6ImFkbWluIiwicm9sZSI6IjAiLCJUb2tlbklkIjoiYjcxOWIxYzEtNmI4MC00N2U1L
//ThjMGQtYjU4ZTAyN2UyMmE4IiwibmJmIjoxNjkwNDUzMTc3LCJleHAiOjE2OTA0NTQ5NzcsImlhdCI6MTY5MDQ1MzE3N30
//.W-0PXJ9GAmwOOXlKi8cEr3lBkwx9rGbpLKCCUYJkyCA");
AuthenticateWithPhoton
(
respondMessage
.
Data
);
}
else
{
message
.
text
=
"Account is not available. Check your email/password and try again."
;
}
}
}
}
}
private
string
CleanInput
(
string
input
)
{
return
input
.
Replace
(
"\u200b"
,
""
).
Trim
();
}
private
async
void
AuthenticateWithPhoton
(
string
token
)
{
using
(
HttpClient
client
=
new
HttpClient
())
{
string
apiURL
=
baseURL
+
token
;
using
(
HttpResponseMessage
res
=
await
client
.
GetAsync
(
apiURL
))
{
if
(
res
.
IsSuccessStatusCode
)
{
// Token is valid. Proceed to connect to Photon.
var
authParameters
=
new
System
.
Collections
.
Generic
.
Dictionary
<
string
,
object
>
{
{
"token"
,
token
}
};
PhotonNetwork
.
AuthValues
=
new
AuthenticationValues
(
JsonUtility
.
ToJson
(
authParameters
));
// Now, connect to Photon servers with the custom authentication values.
PhotonNetwork
.
ConnectUsingSettings
();
}
else
{
// Token is invalid. Handle the error or display a message to the user.
Debug
.
Log
(
"Invalid token. Unable to connect to Photon."
);
message
.
text
=
"Invalid token. Unable to connect to Photon."
;
}
}
}
}
}
UnityProject/Assets/AccountLogin.cs.meta
0 → 100644
View file @
80baba42
fileFormatVersion: 2
guid: c1e86e6b5f0a0c84cacb34b2b1f94e17
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
UnityProject/Assets/FacebookLogin.cs
View file @
80baba42
...
...
@@ -6,11 +6,6 @@ using UnityEngine;
public
class
FacebookLogin
:
MonoBehaviour
{
private
Log
.
LoginSession
session
=
new
Log
.
LoginSession
();
public
string
Token
;
public
string
Error
;
private
bool
isQuitting
=
false
;
private
void
Awake
()
{
if
(!
FB
.
IsInitialized
)
...
...
@@ -64,7 +59,6 @@ public class FacebookLogin : MonoBehaviour
if
(
FB
.
IsLoggedIn
)
{
string
accessToken
=
AccessToken
.
CurrentAccessToken
.
TokenString
;
Token
=
accessToken
;
Debug
.
Log
(
"Facebook Login Successful! Access Token: "
+
accessToken
);
// Continue with Photon authentication
...
...
UnityProject/Assets/GoogleLogin.cs
View file @
80baba42
...
...
@@ -5,8 +5,6 @@ using UnityEngine;
public
class
GoogleLogin
:
MonoBehaviour
{
private
Log
.
LoginSession
session
=
new
Log
.
LoginSession
();
public
void
OnGoogleLoginButtonClicked
()
{
PlayGamesPlatform
.
DebugLogEnabled
=
true
;
...
...
UnityProject/Assets/Scenes/
SampleScene
.unity
→
UnityProject/Assets/Scenes/
Login
.unity
View file @
80baba42
This diff is collapsed.
Click to expand it.
UnityProject/Assets/Scenes/
SampleScene
.unity.meta
→
UnityProject/Assets/Scenes/
Login
.unity.meta
View file @
80baba42
File moved
UnityProject/Assets/Scenes/Main.unity
0 → 100644
View file @
80baba42
%YAML
1.1
%TAG
!u!
tag:unity3d.com,2011:
---
!u!29
&1
OcclusionCullingSettings
:
m_ObjectHideFlags
:
0
serializedVersion
:
2
m_OcclusionBakeSettings
:
smallestOccluder
:
5
smallestHole
:
0.25
backfaceThreshold
:
100
m_SceneGUID
:
00000000000000000000000000000000
m_OcclusionCullingData
:
{
fileID
:
0
}
---
!u!104
&2
RenderSettings
:
m_ObjectHideFlags
:
0
serializedVersion
:
9
m_Fog
:
0
m_FogColor
:
{
r
:
0.5
,
g
:
0.5
,
b
:
0.5
,
a
:
1
}
m_FogMode
:
3
m_FogDensity
:
0.01
m_LinearFogStart
:
0
m_LinearFogEnd
:
300
m_AmbientSkyColor
:
{
r
:
0.212
,
g
:
0.227
,
b
:
0.259
,
a
:
1
}
m_AmbientEquatorColor
:
{
r
:
0.114
,
g
:
0.125
,
b
:
0.133
,
a
:
1
}
m_AmbientGroundColor
:
{
r
:
0.047
,
g
:
0.043
,
b
:
0.035
,
a
:
1
}
m_AmbientIntensity
:
1
m_AmbientMode
:
3
m_SubtractiveShadowColor
:
{
r
:
0.42
,
g
:
0.478
,
b
:
0.627
,
a
:
1
}
m_SkyboxMaterial
:
{
fileID
:
0
}
m_HaloStrength
:
0.5
m_FlareStrength
:
1
m_FlareFadeSpeed
:
3
m_HaloTexture
:
{
fileID
:
0
}
m_SpotCookie
:
{
fileID
:
10001
,
guid
:
0000000000000000e000000000000000
,
type
:
0
}
m_DefaultReflectionMode
:
0
m_DefaultReflectionResolution
:
128
m_ReflectionBounces
:
1
m_ReflectionIntensity
:
1
m_CustomReflection
:
{
fileID
:
0
}
m_Sun
:
{
fileID
:
0
}
m_IndirectSpecularColor
:
{
r
:
0
,
g
:
0
,
b
:
0
,
a
:
1
}
m_UseRadianceAmbientProbe
:
0
---
!u!157
&3
LightmapSettings
:
m_ObjectHideFlags
:
0
serializedVersion
:
12
m_GIWorkflowMode
:
1
m_GISettings
:
serializedVersion
:
2
m_BounceScale
:
1
m_IndirectOutputScale
:
1
m_AlbedoBoost
:
1
m_EnvironmentLightingMode
:
0
m_EnableBakedLightmaps
:
0
m_EnableRealtimeLightmaps
:
0
m_LightmapEditorSettings
:
serializedVersion
:
12
m_Resolution
:
2
m_BakeResolution
:
40
m_AtlasSize
:
1024
m_AO
:
0
m_AOMaxDistance
:
1
m_CompAOExponent
:
1
m_CompAOExponentDirect
:
0
m_ExtractAmbientOcclusion
:
0
m_Padding
:
2
m_LightmapParameters
:
{
fileID
:
0
}
m_LightmapsBakeMode
:
1
m_TextureCompression
:
1
m_FinalGather
:
0
m_FinalGatherFiltering
:
1
m_FinalGatherRayCount
:
256
m_ReflectionCompression
:
2
m_MixedBakeMode
:
2
m_BakeBackend
:
1
m_PVRSampling
:
1
m_PVRDirectSampleCount
:
32
m_PVRSampleCount
:
512
m_PVRBounces
:
2
m_PVREnvironmentSampleCount
:
256
m_PVREnvironmentReferencePointCount
:
2048
m_PVRFilteringMode
:
1
m_PVRDenoiserTypeDirect
:
1
m_PVRDenoiserTypeIndirect
:
1
m_PVRDenoiserTypeAO
:
1
m_PVRFilterTypeDirect
:
0
m_PVRFilterTypeIndirect
:
0
m_PVRFilterTypeAO
:
0
m_PVREnvironmentMIS
:
1
m_PVRCulling
:
1
m_PVRFilteringGaussRadiusDirect
:
1
m_PVRFilteringGaussRadiusIndirect
:
5
m_PVRFilteringGaussRadiusAO
:
2
m_PVRFilteringAtrousPositionSigmaDirect
:
0.5
m_PVRFilteringAtrousPositionSigmaIndirect
:
2
m_PVRFilteringAtrousPositionSigmaAO
:
1
m_ExportTrainingData
:
0
m_TrainingDataDestination
:
TrainingData
m_LightProbeSampleCountMultiplier
:
4
m_LightingDataAsset
:
{
fileID
:
0
}
m_LightingSettings
:
{
fileID
:
0
}
---
!u!196
&4
NavMeshSettings
:
serializedVersion
:
2
m_ObjectHideFlags
:
0
m_BuildSettings
:
serializedVersion
:
3
agentTypeID
:
0
agentRadius
:
0.5
agentHeight
:
2
agentSlope
:
45
agentClimb
:
0.4
ledgeDropHeight
:
0
maxJumpAcrossDistance
:
0
minRegionArea
:
2
manualCellSize
:
0
cellSize
:
0.16666667
manualTileSize
:
0
tileSize
:
256
buildHeightMesh
:
0
maxJobWorkers
:
0
preserveTilesOutsideBounds
:
0
debug
:
m_Flags
:
0
m_NavMeshData
:
{
fileID
:
0
}
---
!u!1
&924534202
GameObject
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
serializedVersion
:
6
m_Component
:
-
component
:
{
fileID
:
924534205
}
-
component
:
{
fileID
:
924534204
}
-
component
:
{
fileID
:
924534203
}
m_Layer
:
0
m_Name
:
Main Camera
m_TagString
:
MainCamera
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
---
!u!81
&924534203
AudioListener
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
924534202
}
m_Enabled
:
1
---
!u!20
&924534204
Camera
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
924534202
}
m_Enabled
:
1
serializedVersion
:
2
m_ClearFlags
:
1
m_BackGroundColor
:
{
r
:
0.19215687
,
g
:
0.3019608
,
b
:
0.4745098
,
a
:
0
}
m_projectionMatrixMode
:
1
m_GateFitMode
:
2
m_FOVAxisMode
:
0
m_Iso
:
200
m_ShutterSpeed
:
0.005
m_Aperture
:
16
m_FocusDistance
:
10
m_FocalLength
:
50
m_BladeCount
:
5
m_Curvature
:
{
x
:
2
,
y
:
11
}
m_BarrelClipping
:
0.25
m_Anamorphism
:
0
m_SensorSize
:
{
x
:
36
,
y
:
24
}
m_LensShift
:
{
x
:
0
,
y
:
0
}
m_NormalizedViewPortRect
:
serializedVersion
:
2
x
:
0
y
:
0
width
:
1
height
:
1
near clip plane
:
0.3
far clip plane
:
1000
field of view
:
60
orthographic
:
1
orthographic size
:
5
m_Depth
:
-1
m_CullingMask
:
serializedVersion
:
2
m_Bits
:
4294967295
m_RenderingPath
:
-1
m_TargetTexture
:
{
fileID
:
0
}
m_TargetDisplay
:
0
m_TargetEye
:
3
m_HDR
:
1
m_AllowMSAA
:
1
m_AllowDynamicResolution
:
0
m_ForceIntoRT
:
0
m_OcclusionCulling
:
1
m_StereoConvergence
:
10
m_StereoSeparation
:
0.022
---
!u!4
&924534205
Transform
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
924534202
}
serializedVersion
:
2
m_LocalRotation
:
{
x
:
0
,
y
:
0
,
z
:
0
,
w
:
1
}
m_LocalPosition
:
{
x
:
0
,
y
:
0
,
z
:
-10
}
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_ConstrainProportionsScale
:
0
m_Children
:
[]
m_Father
:
{
fileID
:
0
}
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!1660057539
&9223372036854775807
SceneRoots
:
m_ObjectHideFlags
:
0
m_Roots
:
-
{
fileID
:
924534205
}
UnityProject/Assets/Scenes/Main.unity.meta
0 → 100644
View file @
80baba42
fileFormatVersion: 2
guid: 2cc858c23c576ec44837e5ff1889e937
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
UnityProject/Assets/UserSessionManager.cs
View file @
80baba42
...
...
@@ -6,8 +6,6 @@ using static Log;
public
class
UserSessionManager
:
MonoBehaviour
{
[
SerializeField
]
TextMeshProUGUI
message
;
private
static
LoginSession
currentSession
;
public
static
void
LogIn
(
string
username
)
...
...
@@ -30,7 +28,6 @@ public class UserSessionManager : MonoBehaviour
// Reset the current session
currentSession
=
null
;
PhotonNetwork
.
Disconnect
();
message
.
text
=
"Logged Out! Disconnected from Photon."
;
}
}
}
UnityProject/ProjectSettings/EditorBuildSettings.asset
View file @
80baba42
...
...
@@ -6,6 +6,6 @@ EditorBuildSettings:
serializedVersion
:
2
m_Scenes
:
-
enabled
:
1
path
:
Assets/Scenes/
SampleScene
.unity
path
:
Assets/Scenes/
Login
.unity
guid
:
2cda990e2423bbf4892e6590ba056729
m_configObjects
:
{}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment