Skip to content

Commit

Permalink
Merge pull request #44 from JeevantVerma/main
Browse files Browse the repository at this point in the history
Removed old testing code.
  • Loading branch information
JeevantVerma authored Jun 26, 2024
2 parents 20be0ad + 033ec57 commit 5ccb64e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 58 deletions.
5 changes: 0 additions & 5 deletions backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"net/http"
"os"

auth "github.com/MicrosoftStudentChapter/Link-Generator/pkg/auth"
router "github.com/MicrosoftStudentChapter/Link-Generator/pkg/router"
"github.com/gorilla/mux"
"github.com/redis/go-redis/v9"
Expand All @@ -32,10 +31,6 @@ func main() {

r := mux.NewRouter()
r.HandleFunc("/links/all", router.GetAllLinks).Methods(http.MethodOptions, http.MethodGet)
r.HandleFunc("/generate-token", auth.GenerateJWT).Methods(http.MethodOptions, http.MethodGet)
r.Handle("/login", auth.TokenRequired(http.HandlerFunc(auth.ProtectedRoute))).Methods(http.MethodOptions, http.MethodGet)
r.HandleFunc("/register", auth.Register).Methods(http.MethodOptions, http.MethodPost)
r.HandleFunc("/show/users", auth.ShowUsers).Methods(http.MethodOptions, http.MethodGet)
r.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte("Service is Alive"))
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import { Routes, Route, Link } from 'react-router-dom';
import MainContentSection from './Maincontent';
import Adminpage from './Adminpage';
import "./App.css";
import Administrators from './Adminpagecomponents/Administrators';
import LoginPage from "./LoginPage";

const App = () => {
return (
<div className='app'>
<Routes>
<Route path="/" element={<MainContentSection />} />
<Route path="/Adminpage" element={<Adminpage />} />
<Route path="/Loginpage" element={<LoginPage />} />
</Routes>
</div>
);
Expand Down
52 changes: 0 additions & 52 deletions frontend/src/Maincontent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,41 +34,12 @@ import QRcode from "qrcode";
const MainContentSection = () => {
const [longUrl, setLongUrl] = useState("");
const [alias, setAlias] = useState("");
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
const [shortenedUrl, setShortenedUrl] = useState("");
const [expiry, setExpiry] = useState(dayjs().add(1, "week"));
const [expiryOption, setExpiryOption] = useState("1 week");
const [noExpiry, setNoExpiry] = useState(false);
const [snackbarOpen, setSnackbarOpen] = useState(false);
const [error, setError] = useState("");

const registerUser = async () => {
const userData = JSON.stringify({
user: username,
pass: password,
});

const config = {
method: "POST",
maxBodyLength: Infinity,
url: `http://localhost:4000/register`,
headers: {
"Content-Type": "application/json",
"Access-Control-Allow-Origin":
"https://generate.mlsctiet.com, http://localhost:5173",
},
data: userData,
};
const response = await axios.request(config);

if (response.status == 200) {
console.log(userData);
setShortenedUrl("Login success");
} else {
setShortenedUrl("Login Failed");
}
}
const [qrimage, setqrimage] = useState("");

const handleShortenUrl = async () => {
Expand Down Expand Up @@ -211,24 +182,6 @@ const MainContentSection = () => {
onChange={(e) => setAlias(e.target.value)}
/>
</Grid>
<Grid item xs={12} sx={{ pt: { xs: 32, md: 16 }, pl: 16 }}>
<TextField
label="email"
variant="outlined"
fullWidth
value={username}
onChange={(e) => setUsername(e.target.value)}
/>
</Grid>
<Grid item xs={12} sx={{ pt: { xs: 32, md: 16 }, pl: 16 }}>
<TextField
label="password"
variant="outlined"
fullWidth
value={password}
onChange={(e) => setPassword(e.target.value)}
/>
</Grid>
<Grid item xs={12} sx={{ pt: { xs: 32, md: 16 }, pl: 16 }}>
<LocalizationProvider dateAdapter={AdapterDayjs}>
<DatePicker
Expand Down Expand Up @@ -281,11 +234,6 @@ const MainContentSection = () => {
Shorten URL
</Button>
</Grid>
<Grid item xs={12}>
<Button variant="contained" color="primary" onClick={registerUser}>
Register
</Button>
</Grid>
{shortenedUrl && (
<Grid item xs={12}>
Shortened URL:{" "}
Expand Down

0 comments on commit 5ccb64e

Please sign in to comment.