Conversation
|
I got it to the point where login is working, all my comments and things are still there if you want to go see what is going on, i think we should clean up the auth service post request next and then move too signup and then on from there @samforstot |
…Saucier720 into GMF-ReconnectFrontend
| "net/http" | ||
|
|
||
| "github.com/gorilla/mux" | ||
| "github.com/rs/cors" |
| router.HandleFunc("/UpdateRecipe", makeHTTPHandleFunc(s.handleUpdateRecipe)) | ||
|
|
||
| http.ListenAndServe(s.listenAddr, router) | ||
| c := cors.New(cors.Options{ |
There was a problem hiding this comment.
wrap the whole routing middleware in cors handler, in allowedOrigins i think we have to add each route, ive only done login so thats all that is there
| c := cors.New(cors.Options{ | ||
| AllowedOrigins: []string{"http://localhost:4200", "http://localhost:4200/Login"}, // Add your frontend URLs | ||
| AllowedMethods: []string{"GET", "POST", "PUT", "DELETE"}, | ||
| AllowedHeaders: []string{"*"}, |
There was a problem hiding this comment.
this just allows everything i think * = all ?
|
|
||
| handler := c.Handler(router) | ||
|
|
||
| http.ListenAndServe(s.listenAddr, handler) |
There was a problem hiding this comment.
the handler here used to just be router, this adds the needed CORS stuff
Backend/api.go
Outdated
| Domain: "localhost", | ||
| } | ||
|
|
||
| // http.SetCookie(w, httpCookie) |
There was a problem hiding this comment.
im not sure if this would work? uncomment this, i thought it was breaking it
| </div> | ||
| <div *ngIf="recipes && recipes.length > 0" class="recipe-instructions"> | ||
| <div *ngIf="recipes[currentRecipeIndex].R.instructions" class="recipe-instructions"> | ||
| <div *ngIf="recipes && recipes.RecipeToPost.length > 0" class="recipe-instructions"> |
There was a problem hiding this comment.
to match the recipe update
| ) | ||
| if err != nil { | ||
| fmt.Println("error on cookie post") | ||
| updateCookieerr := s.UpdateCookieByUserName(username, cookie) |
There was a problem hiding this comment.
this was a big thing giving me issues, if there is already a primary key in the database, meaning if a user has already had a cookie, then it cant insert and gives this error 'mssql: Violation of PRIMARY KEY constraint 'PK__user_coo__C9F284575894A090'. Cannot insert duplicate key in object 'dbo.user_cookies'. The duplicate key value is (json).'
There was a problem hiding this comment.
I added error handling so that if this fails then it tries to update, then if that errs it fails
| Domain: "localhost", | ||
| } | ||
|
|
||
| http.SetCookie(w, httpCookie) |
There was a problem hiding this comment.
this sets the cookie from our backend
There was a problem hiding this comment.
supa wild, we should probably implement a better hash system still?
| logoutUrl: 'http://localhost:8080/Logout', | ||
| // Add more routes as needed | ||
| }; | ||
|
|
There was a problem hiding this comment.
interface for the routes to centralize them
| public login(username: string, password: string): Observable<any> { | ||
| const body = { username, password }; | ||
| return this.http.post(this.loginUrl, body, { observe: 'response', responseType: 'json', withCredentials: true }); | ||
| public login(request: LoginRequest): Observable<any> { |
There was a problem hiding this comment.
login is now clamped to a type of LoginRequest
{
UserName: string,
Password: string
}
Frontend Pantry fix for Go Mod Fix
Frontend List fix for Go Mod Fix

Describe your changes
After the backend changes we can optimize angular to work better with the routing changes
Issue ticket number and link