Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 12 additions & 86 deletions Assets/3.1 UIAssets/Scripts/LoginUIButtonManager.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading.Tasks;
using System.Threading;
//using System.Diagnostics;
using System.Net;
using UnityEditor;
using UnityEngine.UI;

public class LoginUIButtonManager : MonoBehaviour
Expand Down Expand Up @@ -40,15 +34,6 @@ public class LoginUIButtonManager : MonoBehaviour
public InputField loginTeacherEmaildData;
public static string loginTeacherEmailCheck;

public static bool cc;

private void Start()
{

cc = false;

//FirebaseLogInManager.Instance2.Init();
}
public void CheackTeacherEmail()
{
loginTeacherEmailCheck = loginTeacherEmaildData.text;
Expand All @@ -66,21 +51,6 @@ public void GetTeacherEmail()
// SSignupUI, TSignupUI에서 회원가입 버튼 클릭 시 LoginUI로 이동
public void LoginUISetActive()
{
//if (CreateBool == false)
//{
// return;
//}
//if (CreateBool == true)
//{
// FirstUI.SetActive(false);
// TSChoiceUI.SetActive(false);
// FindIDUI.SetActive(false);
// FindPWUI.SetActive(false);
// SSignupUI.SetActive(false);
// TSignupUI.SetActive(false);

// LoginUI.SetActive(true);
//}
FirstUI.SetActive(false);
TSChoiceUI.SetActive(false);
FindIDUI.SetActive(false);
Expand Down Expand Up @@ -196,7 +166,6 @@ public void TSignupUISetActive()

// LoginUI에서 뒤로가기 버튼 클릭 시 이전화면(FirstUI)으로 이동
// TSChoiceUI에서 뒤로가기 버튼 클릭 시 이전화면(FirstUI)으로 이동

public void FirstUISetActive()
{
LoginUI.SetActive(false);
Expand All @@ -220,70 +189,27 @@ public void FindPWUISetActive()

}





//IEnumerator WaitForIt()
//{
// yield return new WaitForSeconds(2.0f);
// Debug.LogError("지연됨");

//}
// LoginUI에서 로그인 버튼 클릭 시 메인 화면(Experiment1)으로 이동


public void Experiment1SetActive()
{

//쓰려면 void 왼쪽이 async 해줘
//await Task.Run(() =>
//{
// Debug.LogError("LoginUIButtonManager : 나옴");
// //Debug.LogError("LoginUIButtonManager : " + LogInSystem.password2);
// //LogInSystem.LogIn();
// //LogInSystemScript.GetComponentInChildren<LogInSystem>().LogIn();
//});

LogInSystemScript.GetComponent<FirebaseLogInManager>().Login();


if (cc == true)
LogInSystemScript.GetComponent<FirebaseLogInManager>().Login(isSignedIn =>
{
if (LoginUIButtonManager.lst.Contains(LoginUIButtonManager.loginTeacherEmailCheck))
// signin successed
if (isSignedIn)
{
// To do signin success process
LoginUI.SetActive(false);
Experiment1.SetActive(true);
GroupCodeSet.SetActive(false);

bool isContainTeacherEmail = LoginUIButtonManager.lst.Contains(LoginUIButtonManager.loginTeacherEmailCheck);
GroupCodeSet.SetActive(!isContainTeacherEmail);
}
else
{
LoginUI.SetActive(false);
Experiment1.SetActive(true);
GroupCodeSet.SetActive(true);
// or error handling process
ToastMsg.Instrance.showMessage("아이디 혹은 비밀번호가 틀립니다.", 1.0f);
ImageToast.Instrance.showImage(1.0f);
Debug.Log("Fail");
}
//Debug.LogError("cc = "+cc);


}
if (cc == false)
{
Debug.LogError("cc = false");
ToastMsg.Instrance.showMessage("아이디 혹은 비밀번호가 틀립니다.", 1.0f);
ImageToast.Instrance.showImage(1.0f);
}





});
}

public void Update()
{
//
//Experiment1SetActive();
//cc = FirebaseLogInManager.aa;
}

}
52 changes: 20 additions & 32 deletions Assets/Firebase/FirebaseLogInManager.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Firebase.Auth;
using UnityEngine.UI;

using System;

public class FirebaseLogInManager : MonoBehaviour
{
Expand Down Expand Up @@ -50,18 +50,18 @@ public void Create()
{
if (task.IsCanceled)
{
Debug.LogError("ȸ������ ���");
Debug.LogError("회원가입 취소");
return;
}
if (task.IsFaulted)
{
Debug.LogError("ȸ������ ����");
Debug.LogError("회원가입 실패");
return;
}

FirebaseUser newUser = task.Result.User;
//newUser.User.DisplayName, newUser.User.UserId);
Debug.LogError("ȸ������ �Ϸ�");
Debug.LogError("회원가입 완료");
});
}

Expand All @@ -71,58 +71,46 @@ public void CreateTeacher()
{
if (task.IsCanceled)
{
Debug.LogError("ȸ������ ���");
Debug.LogError("회원가입 취소");
return;
}
if (task.IsFaulted)
{
Debug.LogError("ȸ������ ����");
Debug.LogError("회원가입 실패");
return;
}

FirebaseUser newUser = task.Result.User;
//newUser.User.DisplayName, newUser.User.UserId);
Debug.LogError("ȸ������ �Ϸ�");
Debug.LogError("회원가입 완료");
});
}

public void Login()
public void Login(Action<bool> isSignedIn)
{
auth.SignInWithEmailAndPasswordAsync(email.text, password.text).ContinueWith(task =>
{

if (task.IsCanceled)
{
//Debug.LogError("��� ���");
LoginUIButtonManager.cc = false;
return;
Debug.LogError("로그인 취소");
isSignedIn?.Invoke(false);
}
if (task.IsFaulted)
else if (task.IsFaulted)
{
Debug.LogError("��� ����");
LoginUIButtonManager.cc = false;
return;
Debug.LogError("로그인 실패");
isSignedIn?.Invoke(false);
}


LoginUIButtonManager.cc = true;
FirebaseUser newUser = task.Result.User;

//FirebaseUser newUser = task.Result;
Debug.LogError("�α��� �Ϸ�");


//loginUIButtonManager.Experiment1SetActive();
else
{
Debug.LogError("로그인 완료");
isSignedIn?.Invoke(true);
}
});




}

public void LogOut()
{
auth.SignOut();
Debug.Log("�α׾ƿ�");
Debug.Log("로그아웃");
}
}