Skip to content

Commit

Permalink
♻️ Fix 기능 수정
Browse files Browse the repository at this point in the history
-연결코드/인증코드 만료시각 추가
-인증코드 메일전송 기능 추가
-유저상태/로그인상태에 따른 앱실행 분기 수정

Related to:#60
  • Loading branch information
pakkyunn committed Jul 10, 2024
1 parent 3ee4af8 commit 96c9bd2
Show file tree
Hide file tree
Showing 18 changed files with 410 additions and 356 deletions.
27 changes: 13 additions & 14 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:label="woo_yeon_hi"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
android:icon="@mipmap/ic_launcher"
android:label="woo_yeon_hi">
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<!-- Deep Links -->
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

</activity>
Expand All @@ -54,8 +53,8 @@
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
<queries>
<intent>
<action android:name="android.intent.action.PROCESS_TEXT"/>
<data android:mimeType="text/plain"/>
<action android:name="android.intent.action.PROCESS_TEXT" />
<data android:mimeType="text/plain" />
</intent>
</queries>
</manifest>
</manifest>
7 changes: 2 additions & 5 deletions lib/dao/login_register_dao.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:woo_yeon_hi/dao/user_dao.dart';

import '../model/user_model.dart';

Future<bool> saveConnectCodeData(String code, int idx) async {
var querySnapshot = await FirebaseFirestore.instance
.collection('CodeData')
Expand All @@ -14,7 +12,8 @@ Future<bool> saveConnectCodeData(String code, int idx) async {
await FirebaseFirestore.instance.collection('CodeData').add({
'connect_code': code,
'host_idx': idx,
'code_connect_state': false
'code_connect_state': false,
'expired_time': DateTime.now().add(const Duration(minutes: 5)).toIso8601String(),
});
return true;
}
Expand Down Expand Up @@ -68,8 +67,6 @@ Future<bool> isCodeConnected(String code) async {
return false;
}



Future<void> saveUserInfo(String userAccount) async {
try {
var userIdx = await getUserSequence() + 1;
Expand Down
3 changes: 2 additions & 1 deletion lib/dao/more_dao.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Future<bool> saveAuthCodeData(String code, int idx) async {
await FirebaseFirestore.instance.collection('CodeData').add({
'auth_code': code,
'user_idx': idx,
'expired_time': DateTime.now().add(const Duration(minutes: 5)).toIso8601String(),
});
return true;
}
Expand All @@ -59,7 +60,7 @@ Future<String?> isVerifiedCode(String code, int idx) async {
for (var doc in querySnapShot.docs) {
results = doc.data();
}
if(results['user_idx']==idx){
if(results['user_idx'] == idx && DateTime.now().isBefore(DateTime.parse(results['expired_time']))){
result = results['auth_code'];
} else {
result = null;
Expand Down
2 changes: 1 addition & 1 deletion lib/dao/user_dao.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Future<void> saveUserData(UserModel user) async {
"home_preset_type": user.homePresetType,
"top_bar_type": user.topBarType,
"profile_message": user.profileMessage,
"alarms_allow": user.alarmsAllow,
"notification_allow": user.notificationAllow,
"top_bar_activate": user.topBarActivate,
"user_state": user.userState,
"love_dDay": user.loveDday,
Expand Down
32 changes: 13 additions & 19 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,19 @@ Future<void> main() async {
initializeDateFormatting().then((_) async {
final userData = await fetchUserData();


runApp(MultiProvider(
providers: [
ChangeNotifierProvider(create: (context) => UserProvider())
],
child: WooYeonHi(
userIdx: userData['userIdx'],
userAccount: userData['userAccount'],
alarmsAllow: userData['alarmsAllow'],
appLockState: userData['appLockState'],
homePresetType: userData['homePresetType'],
loginType: userData['loginType'],
loveDday: userData['loveDday'],
loverIdx: userData['loverIdx'],
notificationAllow: userData['notificationAllow'],
profileMessage: userData['profileMessage'],
topBarActivate: userData['topBarActivate'],
topBarType: userData['topBarType'],
Expand All @@ -66,15 +65,14 @@ Future<void> main() async {
class WooYeonHi extends StatefulWidget {
WooYeonHi(
{super.key,

required this.userIdx,
required this.userAccount,
required this.alarmsAllow,
required this.appLockState,
required this.homePresetType,
required this.loginType,
required this.loveDday,
required this.loverIdx,
required this.notificationAllow,
required this.profileMessage,
required this.topBarActivate,
required this.topBarType,
Expand All @@ -85,12 +83,12 @@ class WooYeonHi extends StatefulWidget {

final int userIdx;
final String userAccount;
final bool alarmsAllow;
final int appLockState;
final int homePresetType;
final int loginType;
final String loveDday;
final int loverIdx;
final bool notificationAllow;
final String profileMessage;
final bool topBarActivate;
final int topBarType;
Expand All @@ -107,8 +105,7 @@ class _WooYeonHiState extends State<WooYeonHi> {
@override
build(BuildContext context) {

Provider.of<UserProvider>(context, listen: false).setUserAllData(widget.userIdx, widget.userAccount, widget.alarmsAllow, widget.appLockState, widget.homePresetType, widget.loginType, widget.loveDday, widget.loverIdx, widget.profileMessage, widget.topBarActivate, widget.topBarType, widget.userBirth, widget.userNickname, widget.userProfileImage, widget.userState);

Provider.of<UserProvider>(context, listen: false).setUserAllData(widget.userIdx, widget.userAccount, widget.appLockState, widget.homePresetType, widget.loginType, widget.loveDday, widget.loverIdx, widget.notificationAllow, widget.profileMessage, widget.topBarActivate, widget.topBarType, widget.userBirth, widget.userNickname, widget.userProfileImage, widget.userState);
return MultiProvider(
providers: [
ChangeNotifierProvider(create: (context) => CalendarProvider()),
Expand All @@ -118,12 +115,9 @@ class _WooYeonHiState extends State<WooYeonHi> {
ChangeNotifierProvider(create: (context) => DiaryProvider()),
ChangeNotifierProvider(create: (context) => FootprintProvider()),
ChangeNotifierProvider(create: (context) => LedgerProvider()),
ChangeNotifierProvider(
create: (context) => FootPrintSlidableProvider()),
ChangeNotifierProvider(
create: (context) => FootPrintDatePlanSlidableProvider()),
ChangeNotifierProvider(
create: (context) => FootprintDraggableSheetProvider()),
ChangeNotifierProvider(create: (context) => FootPrintSlidableProvider()),
ChangeNotifierProvider(create: (context) => FootPrintDatePlanSlidableProvider()),
ChangeNotifierProvider(create: (context) => FootprintDraggableSheetProvider()),
ChangeNotifierProvider(create: (context) => BioAuthProvider()),
ChangeNotifierProvider(create: (context) => PasswordProvider()),
],
Expand All @@ -145,13 +139,13 @@ class _WooYeonHiState extends State<WooYeonHi> {
onSurface: Colors.black,
),
useMaterial3: true),
home: widget.userIdx == 0
home: widget.userIdx == 0 // 미등록 계정
? const LoginScreen()
: widget.userState == 1
? const LoginScreen()
: widget.appLockState == 0
? const MainScreen()
: const PasswordEnterScreen(),
: widget.userState == 0 // 등록계정 & 계정상태 정상
? widget.appLockState == 0 // 앱 잠금 미설정
? const MainScreen()
: const PasswordEnterScreen() // 앱 잠금 설정
: const LoginScreen(), // 등록계정 & 계정상태 비정상(삭제처리중/로그아웃)
onGenerateRoute: RouteGenerator.generateRoute,
));
}
Expand Down
6 changes: 3 additions & 3 deletions lib/model/user_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class UserModel{
int homePresetType;
int topBarType;
String profileMessage;
bool alarmsAllow;
bool notificationAllow;
bool topBarActivate;
int userState;
String loveDday;
Expand All @@ -34,7 +34,7 @@ class UserModel{
required this.homePresetType,
required this.topBarType,
required this.profileMessage,
required this.alarmsAllow,
required this.notificationAllow,
required this.topBarActivate,
required this.userState,
required this.loveDday,
Expand All @@ -54,7 +54,7 @@ class UserModel{
homePresetType: data['home_preset_type'],
topBarType: data['top_bar_type'],
profileMessage: data['profile_message'],
alarmsAllow: data['alarms_allow'],
notificationAllow: data['notification_allow'],
topBarActivate: data['top_bar_activate'],
userState: data['user_state'],
loveDday: data['love_d_day'],
Expand Down
12 changes: 6 additions & 6 deletions lib/provider/login_register_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import '../dialogs.dart';
class UserProvider extends ChangeNotifier {
int _userIdx = 0;
String _userAccount = "";
bool _alarmsAllow = false;
bool _notificationAllow = false;
int _appLockState = 0;
int _homePresetType = 0;
int _loginType = 0;
Expand All @@ -33,7 +33,7 @@ class UserProvider extends ChangeNotifier {

String get userAccount => _userAccount;

bool get alarmsAllow => _alarmsAllow;
bool get notificationAllow => _notificationAllow;

int get appLockState => _appLockState;

Expand Down Expand Up @@ -143,8 +143,8 @@ class UserProvider extends ChangeNotifier {
notifyListeners();
}

void setAlarmsAllow(bool allow) {
_alarmsAllow = allow;
void setNotificationAllow(bool allow) {
_notificationAllow = allow;
notifyListeners();
}

Expand All @@ -171,12 +171,12 @@ class UserProvider extends ChangeNotifier {
void setUserAllData(
int userIdx,
String userAccount,
bool alarmsAllow,
int appLockState,
int homePresetType,
int loginType,
String loveDday,
int loverIdx,
bool notificationAllow,
String profileMessage,
bool topBarActivate,
int topBarType,
Expand All @@ -186,12 +186,12 @@ class UserProvider extends ChangeNotifier {
int userState) {
_userIdx = userIdx;
_userAccount = userAccount;
_alarmsAllow = alarmsAllow;
_appLockState = appLockState;
_homePresetType = homePresetType;
_loginType = loginType;
_loveDday = loveDday;
_loverIdx = loverIdx;
_notificationAllow = notificationAllow;
_profileMsg = profileMessage;
_topBarActivate = topBarActivate;
_topBarType = topBarType;
Expand Down
33 changes: 17 additions & 16 deletions lib/screen/login/login_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,8 @@ class _RegisterScreen extends State<LoginScreen> {
),
child: InkWell(
onTap: () async {
switch (await getSpecificUserData(provider.userIdx, "user_state")??2) {
case 0:
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) =>
const MainScreen()));
case 1:
Navigator.of(context).push(MaterialPageRoute(
builder: (context) =>
const AccountProcessingScreen()));

case 2:
switch (await getSpecificUserData(provider.userIdx, "user_state")??0) {
case 0: // 미등록 계정
await signInWithGoogle();
if (loginSuccess == true) {
provider.setLoginType(1);
Expand All @@ -151,9 +140,21 @@ class _RegisterScreen extends State<LoginScreen> {
context,
MaterialPageRoute(
builder: (context) =>
const CodeConnectScreen()));
const CodeConnectScreen()));
showBlackToast("구글 계정으로 로그인 되었습니다.");
}

case 1: // 삭제처리중 계정
Navigator.of(context).push(MaterialPageRoute(
builder: (context) =>
const AccountProcessingScreen()));

case 2: // 로그아웃 계정
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) =>
const MainScreen()));
}
},
borderRadius: BorderRadius.circular(20.0),
Expand All @@ -169,7 +170,7 @@ class _RegisterScreen extends State<LoginScreen> {
"lib/assets/icons/google_logo.svg",
height: 24,
width: 24)),
const Text("구글 계정으로 등록하기",
const Text("구글 계정으로 로그인하기",
style: TextStyleFamily.smallTitleTextStyle),
const SizedBox(height: 24, width: 24)
],
Expand Down Expand Up @@ -230,7 +231,7 @@ class _RegisterScreen extends State<LoginScreen> {
"lib/assets/icons/kakao_logo.svg",
height: 24,
width: 24)),
const Text("카카오 계정으로 등록하기",
const Text("카카오 계정으로 로그인하기",
style: TextStyle(
fontSize: 15,
fontFamily: FontFamily.mapleStoryLight,
Expand Down
2 changes: 1 addition & 1 deletion lib/screen/login/password_enter_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ class _PasswordEnterScreenState extends State<PasswordEnterScreen> {

Future<List<int>> _fetchPassword() async {
const storage = FlutterSecureStorage();
List<int> lockPassword = stringToList(((await storage.read(key: "lockPassword")) ?? ""));
List<int> lockPassword = stringToList(((await storage.read(key: "lockPassword")) ?? "10,10,10,10"));
return lockPassword;
}

Expand Down
Loading

0 comments on commit 96c9bd2

Please sign in to comment.