Skip to content

Commit

Permalink
Merge branch 'main' into 1042-chore-alter-redirect-uri-based-on-appli…
Browse files Browse the repository at this point in the history
…cation-communicating-with-be
  • Loading branch information
garrettladley authored Jun 18, 2024
2 parents bec18c7 + 3da58bd commit 50a9f51
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 40 deletions.
14 changes: 8 additions & 6 deletions backend/entities/auth/base/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ func FindOrCreateUser(ctx context.Context, db *gorm.DB, user soth.User) (*models
var sacUser models.User
if err := db.WithContext(ctx).Where("email = ?", user.Email).First(&sacUser).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
if err := createUser(ctx, db, user.Into()); err != nil {
user, err := createUser(ctx, db, *user.Into())
if err != nil {
return nil, err
}
return user, nil
} else {
return nil, err
}
Expand All @@ -24,24 +26,24 @@ func FindOrCreateUser(ctx context.Context, db *gorm.DB, user soth.User) (*models
return &sacUser, nil
}

func createUser(ctx context.Context, db *gorm.DB, user *models.User) error {
func createUser(ctx context.Context, db *gorm.DB, user models.User) (*models.User, error) {
tx := db.WithContext(ctx).Begin()
defer func() {
if r := recover(); r != nil {
tx.Rollback()
}
}()

if err := tx.Create(user).Error; err != nil {
if err := tx.Create(&user).Error; err != nil {
tx.Rollback()
return err
return nil, err
}

welcomeTask := models.WelcomeTask{Name: user.Name, Email: user.Email}
if err := tx.Create(&welcomeTask).Error; err != nil {
tx.Rollback()
return err
return nil, err
}

return tx.Commit().Error
return &user, tx.Commit().Error
}
2 changes: 2 additions & 0 deletions backend/integrations/oauth/soth/sothic/sothic.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,11 @@ func updateSessionValue(session *session.Session, key, value string) error {
if _, err := gz.Write([]byte(value)); err != nil {
return err
}

if err := gz.Flush(); err != nil {
return err
}

if err := gz.Close(); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@generatesac/lib",
"version": "0.0.179",
"version": "0.0.180",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
5 changes: 3 additions & 2 deletions frontend/lib/src/api/base.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";

export const API_BASE_URL = "http://127.0.0.1:8080/api/v1";
export const LOCAL_API_BASE_URL = "http://localhost:3000/api/v1";
export const PROD_API_BASE_URL = "https://studentactivitycalendar.xyz/api/v1";

// BaseAPI for the entire application:
export const baseApi = createApi({
baseQuery: fetchBaseQuery({
baseUrl: API_BASE_URL,
baseUrl: PROD_API_BASE_URL,
credentials: "include",
prepareHeaders: async (headers, { getState }) => {
// User slice existing must exist in all dependent apps:
Expand Down
2 changes: 1 addition & 1 deletion frontend/mobile/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"expo": {
"name": "sac-mobile",
"slug": "student-activity-calendar",
"version": "1.0.3",
"version": "1.0.4",
"orientation": "portrait",
"icon": "./src/assets/images/icon.png",
"scheme": "myapp",
Expand Down
2 changes: 1 addition & 1 deletion frontend/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@fortawesome/free-solid-svg-icons": "^6.5.2",
"@fortawesome/react-fontawesome": "^0.2.2",
"@fortawesome/react-native-fontawesome": "^0.3.2",
"@generatesac/lib": "0.0.179",
"@generatesac/lib": "0.0.180",
"@gorhom/bottom-sheet": "^4.6.3",
"@hookform/resolvers": "^3.4.2",
"@react-native-async-storage/async-storage": "^1.23.1",
Expand Down
19 changes: 0 additions & 19 deletions frontend/mobile/src/app/auth/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React from 'react';
import { Image, Linking, SafeAreaView } from 'react-native';

import { router } from 'expo-router';

import { authApi } from '@generatesac/lib';

import Loading from '@/src/assets/gif/loading.gif';
Expand Down Expand Up @@ -57,23 +55,6 @@ const WelcomePage = () => {
'Continue with Outlook'
)}
</Button>
<Button
variant="standardButton"
color="darkRed"
onPress={() => router.navigate('/auth/callback')}
>
{isLoading ? (
<Image
source={Loading}
style={{
width: 15,
height: 15
}}
/>
) : (
'View Callback'
)}
</Button>
</Box>
</GlobalLayout>
</SafeAreaView>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,15 @@ function convertNumToTime(num: number) {
let meridiem = num === 23 ? 'AM' : 'PM';
let minutes = num % 100;

if (num !== 0 && (num < 1000 || num > 2359)) {
if (num !== 0 && (num < 0 || num > 2359)) {
throw new Error('Invalid time');
}

time = time / 100;

if (num < 12) {
time += 12;
if (time < 12) {
meridiem = 'AM';
}
if (num > 12) {
if (time > 12) {
time -= 12;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const EventCardBig: React.FC<EventCardBigProps> = ({
return (
<Box>
<TouchableOpacity
onPress={() => router.navigate(`/event/${eventId}`)}
onPress={() => router.navigate(`/app/event/${eventId}`)}
>
<Box gap="xs">
<Image
Expand Down
8 changes: 4 additions & 4 deletions frontend/mobile/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1402,10 +1402,10 @@
humps "^2.0.1"
prop-types "^15.7.2"

"@generatesac/[email protected].179":
version "0.0.179"
resolved "https://registry.yarnpkg.com/@generatesac/lib/-/lib-0.0.179.tgz#48941b9f059bcfc5508291bfa86d2c1f7c03d3da"
integrity sha512-N44CToFq1EDAJKnulpvPRkAp8GmC5x/T4NVSx5jO1de3YAMJX7r9vg+99eLHDkhAc+jZPyEckAiQQCfpG+uEsA==
"@generatesac/[email protected].180":
version "0.0.180"
resolved "https://registry.yarnpkg.com/@generatesac/lib/-/lib-0.0.180.tgz#01a5866af05ccbd369e14faddb8acb2745b9fece"
integrity sha512-UxIBGebRwwHdNyX8CHMmMTbC6WwQMKbvzAtRGCZyMvkldasw+XdQ9+F+WzZyR6OF1Lp84VLJsF6UAIYLO1slVQ==
dependencies:
"@reduxjs/toolkit" "^2.2.3"
react "^18.2.0"
Expand Down

0 comments on commit 50a9f51

Please sign in to comment.