-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(licence): implement license key
- Loading branch information
1 parent
57807c1
commit eab2249
Showing
7 changed files
with
400 additions
and
79 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,47 @@ | ||
import { | ||
CHECK_FOR_VALID_LICENSE, | ||
CHECK_FOR_VALID_LICENSE_RESPONSE, | ||
ACTIVATE_LICENSE, | ||
ACTIVATE_LICENSE_RESPONSE, | ||
} from './types' | ||
|
||
export const checkLicensePresent = (token) => ({ | ||
type: CHECK_FOR_VALID_LICENSE, | ||
payload: { token }, | ||
}) | ||
|
||
export const checkLicensePresentResponse = (isLicenseValid) => ({ | ||
type: CHECK_FOR_VALID_LICENSE_RESPONSE, | ||
payload: { isLicenseValid }, | ||
}) | ||
CHECK_FOR_VALID_LICENSE, | ||
CHECK_FOR_VALID_LICENSE_RESPONSE, | ||
ACTIVATE_LICENSE, | ||
ACTIVATE_LICENSE_RESPONSE, | ||
ACTIVATE_CHECK_USER_API, | ||
ACTIVATE_CHECK_LICENCE_API_VALID, | ||
ACTIVATE_CHECK_USER_LICENSE_KEY_RESPONSE, | ||
ACTIVATE_CHECK_USER_LICENSE_KEY, | ||
} from './types' | ||
|
||
export const activateLicense = (licenseKey, token) => ({ | ||
type: ACTIVATE_LICENSE, | ||
payload: { licenseKey, token }, | ||
}) | ||
export const checkLicensePresent = (token) => ({ | ||
type: CHECK_FOR_VALID_LICENSE, | ||
payload: { token }, | ||
}) | ||
|
||
export const activateLicenseResponse = (isLicenseValid) => ({ | ||
type: ACTIVATE_LICENSE_RESPONSE, | ||
payload: { isLicenseValid }, | ||
}) | ||
export const checkUserApi = (payload) => ({ | ||
type: ACTIVATE_CHECK_USER_API, | ||
payload: { payload }, | ||
}) | ||
|
||
export const checkUserLicenceKey = (payload) => ({ | ||
type: ACTIVATE_CHECK_USER_LICENSE_KEY, | ||
payload: { payload }, | ||
}) | ||
export const checkUserApiKeyResponse = (payload) => ({ | ||
type: ACTIVATE_CHECK_LICENCE_API_VALID, | ||
payload: payload, | ||
}) | ||
export const checkUserLicenseKeyResponse = (payload) => ({ | ||
type: ACTIVATE_CHECK_USER_LICENSE_KEY_RESPONSE, | ||
payload: payload, | ||
}) | ||
export const checkLicensePresentResponse = (isLicenseValid) => ({ | ||
type: CHECK_FOR_VALID_LICENSE_RESPONSE, | ||
payload: { isLicenseValid }, | ||
}) | ||
|
||
export const activateLicense = (licenseKey, token) => ({ | ||
type: ACTIVATE_LICENSE, | ||
payload: { licenseKey, token }, | ||
}) | ||
|
||
export const activateLicenseResponse = (isLicenseValid) => ({ | ||
type: ACTIVATE_LICENSE_RESPONSE, | ||
payload: { isLicenseValid }, | ||
}) |
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,69 @@ | ||
export default class LicenseApi { | ||
constructor(api) { | ||
this.api = api | ||
} | ||
getIsActive = () => { | ||
return new Promise((resolve, reject) => { | ||
this.api.isLicenseActive((error, data) => { | ||
this.handleResponse(error, reject, resolve, data) | ||
}) | ||
}) | ||
} | ||
|
||
submitApiKey = (data) => { | ||
const options = {} | ||
options['licenseSpringCredentials'] = data | ||
return new Promise((resolve, reject) => { | ||
this.api.saveLicenseApiCredentials(options, (error, data) => { | ||
this.handleResponse(error, reject, resolve, data) | ||
}) | ||
}) | ||
} | ||
submitLicenseKey = (data) => { | ||
const options = {} | ||
options['licenseApiRequest'] = data | ||
return new Promise((resolve, reject) => { | ||
this.api.activateAdminuiLicense(options, (error, data) => { | ||
this.handleResponse(error, reject, resolve, data) | ||
}) | ||
}) | ||
} | ||
|
||
addPermission = (data) => { | ||
const options = {} | ||
options['adminPermission'] = data | ||
return new Promise((resolve, reject) => { | ||
this.api.addAdminuiPermission(options, (error, data) => { | ||
this.handleResponse(error, reject, resolve, data) | ||
}) | ||
}) | ||
} | ||
|
||
editPermission = (data) => { | ||
const options = {} | ||
options['adminPermission'] = data | ||
return new Promise((resolve, reject) => { | ||
this.api.editAdminuiPermission(options, (error, data) => { | ||
this.handleResponse(error, reject, resolve, data) | ||
}) | ||
}) | ||
} | ||
permission | ||
deletePermission = async (data) => { | ||
const options = {} | ||
options['adminPermission'] = data | ||
return new Promise((resolve, reject) => { | ||
this.api.deleteAdminuiPermission(options, (error, data) => { | ||
this.handleResponse(error, reject, resolve, data) | ||
}) | ||
}) | ||
} | ||
|
||
handleResponse(error, reject, resolve, data) { | ||
if (error) { | ||
reject(error) | ||
} else { | ||
resolve(data) | ||
} | ||
} | ||
} |
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
Oops, something went wrong.