-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/Blueprint-Boulder/f23-Portl…
…andIndigenousMarketplace merging diverged branches
- Loading branch information
Showing
21 changed files
with
218 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,20 @@ | ||
// import Permission from './Permission.js'; | ||
import Cookies from 'js-cookie'; | ||
import {jwtDecode} from 'jwt-decode'; | ||
|
||
/* | ||
Storage mechanism for the currently logged-in user. | ||
*/ | ||
export default class User { | ||
constructor(id, name, email, isadmin, phone_number=null, website=null) { | ||
constructor(id, name, email, isadmin, phoneNumber=null, website=null) { | ||
this.id = id; | ||
this.name = name; | ||
this.email = email; | ||
this.isadmin = isadmin; | ||
this.phone_number = phone_number; | ||
this.phoneNumber = phoneNumber; | ||
this.website = website; | ||
} | ||
|
||
// isAdmin() { | ||
// return this.permission === Permission.Admin; | ||
// } | ||
|
||
// isVendor() { | ||
// return this.permission === Permission.Vendor; | ||
// } | ||
|
||
static createFromCookie() { | ||
if (Cookies.get('auth_pim') != undefined) { | ||
const cookie = Cookies.get('auth_pim'); | ||
const decode = jwtDecode(cookie); | ||
|
||
return User(decode.admin_id, decode.name, decode.email, true, null, null); | ||
} else if ( Cookies.get('auth') != undefined ) { | ||
const cookie = Cookies.get('auth'); | ||
const decode = jwtDecode(cookie); | ||
|
||
return User(decode.vendor_id, decode.name, decode.email, false, decode.phone_number, decode.website); | ||
} else { | ||
return undefined; | ||
} | ||
static newUserFromCookie(cookie, isadmin) { | ||
const decode = jwtDecode(cookie); | ||
if (isadmin) return new User(decode.admin_id, decode.name, decode.email, isadmin, null, null); | ||
return new User(decode.vendor_id, decode.name, decode.email, isadmin, decode.phone_number, decode.website); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export default class AdminsRepository { | ||
constructor(httpClient) { | ||
this.httpClient = httpClient; | ||
} | ||
async authenticateAdmin(adminData) { | ||
try { | ||
const response = await this.httpClient.axiosInstance.post('admins/login', adminData); | ||
// this.httpClient.processCookie(response.headers['set-cookie'][0]); | ||
return response; | ||
} catch (error) { | ||
console.error('Error logging in admin:'); | ||
} | ||
} | ||
|
||
async createAdmin(adminData) { | ||
try { | ||
const response = await this.httpClient.axiosInstance.post('/admins', adminData); | ||
return response.data; | ||
} catch (error) { | ||
console.error('Error creating admin:'); | ||
throw error; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import AdminsRepository from './AdminsRepository.js'; | ||
|
||
export default class AdminsService { | ||
constructor(httpClient) { | ||
this.httpClient = httpClient; | ||
this.adminsRepository = new AdminsRepository(httpClient); | ||
} | ||
|
||
async authenticateAdmin(adminData) { | ||
const response = await this.adminsRepository.authenticateAdmin(adminData); | ||
return response; | ||
} | ||
|
||
async createAdmin(adminData) { | ||
return await this.adminsRepository.createAdmin(adminData); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.