This commit is contained in:
Timo Knuth
2026-02-27 15:19:24 +01:00
parent b7f8221095
commit 253c3c1c6d
134 changed files with 11188 additions and 1871 deletions

View File

@@ -8,6 +8,8 @@ import { SafeAreaView } from 'react-native-safe-area-context'
import { Ionicons } from '@expo/vector-icons'
import { authClient } from '@/lib/auth-client'
import { useAuthStore } from '@/store/auth.store'
import { getApiBaseUrl } from '@/lib/api-url'
import { getOrgSlug } from '@/lib/org-config'
export default function LoginScreen() {
const router = useRouter()
@@ -36,9 +38,27 @@ export default function LoginScreen() {
}
const token = (result.data as any)?.session?.token
const user = (result.data as any)?.user
const rawUser = (result.data as any)?.user
const user = rawUser
? {
id: rawUser.id,
email: rawUser.email,
name: rawUser.name,
mustChangePassword: rawUser.mustChangePassword ?? false,
}
: null
await setSession(user ? { user } : null, token)
// Retroaktive Org-Bindung: idempotent, schlägt still fehl wenn bereits verknüpft
const orgSlug = getOrgSlug()
const emailClean = email.trim().toLowerCase()
const nameForSignup = user?.name?.trim() || emailClean.split('@')[0]
fetch(`${getApiBaseUrl()}/api/registrierung/${orgSlug}/signup`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name: nameForSignup, email: emailClean }),
}).catch(() => {/* ignore */})
setLoading(false)
router.replace('/(app)/home' as never)
}
@@ -113,9 +133,12 @@ export default function LoginScreen() {
</TouchableOpacity>
</View>
<Text style={styles.hint}>
Noch kein Zugang? Kontaktieren Sie Ihre Innungsgeschäftsstelle.
</Text>
<TouchableOpacity onPress={() => router.push('/(auth)/registrierung' as never)}>
<Text style={styles.hint}>
Noch kein Konto?{' '}
<Text style={styles.registerLink}>Jetzt registrieren</Text>
</Text>
</TouchableOpacity>
</View>
</KeyboardAvoidingView>
</SafeAreaView>
@@ -157,4 +180,5 @@ const styles = StyleSheet.create({
submitContent: { flexDirection: 'row', alignItems: 'center', gap: 6 },
submitLabel: { color: '#FFFFFF', fontWeight: '700', fontSize: 15 },
hint: { marginTop: 24, textAlign: 'center', color: '#64748B', fontSize: 13, lineHeight: 18 },
registerLink: { color: '#003B7E', fontWeight: '700' },
})