Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

32 user auth #40

Merged
merged 2 commits into from
Apr 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions frontend/src/app/post.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,15 @@ export interface User{
last_name: string;
email:string;
pronouns:string;
permissions: [];
permissions: Permission[];
}

export interface Permission {
id?: number;
action: string;
resource: string;
}

export interface Post {
id: number;
content: string;
Expand Down Expand Up @@ -55,17 +62,18 @@ export class PostService {
}

makePost(id: number, content: string, user: Profile, votes: [], timestamp: string): Observable<Post> {
let u: User = {id:2, pid:100000000, onyen:'sol', first_name:"Sol", last_name:"Student", email:"[email protected]", pronouns:"they / them",permissions:[]};

let post: Post = {id:id, content: content, user: u, votes: votes, timestamp:timestamp};
console.log("Made it to api call")
console.log(JSON.stringify(post))
try{
return this.http.post<Post>("/api/post", post);
}catch (err){
return throwError(() => new Error("Unable to Post from unregistered user"));
if(user.id && user.first_name && user.last_name && user.email && user.pronouns){
let u: User = {id: user.id, pid:user.pid, onyen: user.onyen, first_name:user.first_name, last_name:user.last_name, email:user.email, pronouns:user.pronouns, permissions: user.permissions};
let post: Post = {id:id, content: content, user: u, votes: votes, timestamp:timestamp};
console.log("Made it to api call")
console.log(JSON.stringify(post))
try{
return this.http.post<Post>("/api/post", post);
}catch (err){
return throwError(() => new Error("Unable to Post from unregistered user"));
}
}

return throwError(() => new Error("Unable to Post from user"));
}

// deletePost(id: number) {
Expand Down