Skip to content

Instantly share code, notes, and snippets.

@adamcameron
Created August 28, 2022 10:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamcameron/003bd626e88e0b4557642938f29e9b2d to your computer and use it in GitHub Desktop.
Save adamcameron/003bd626e88e0b4557642938f29e9b2d to your computer and use it in GitHub Desktop.
Code review for Ookma
function index( event, rc, prc ){
prc.pageTitle = "Reset Password";
if( isEmpty( rc?.user ) || isEmpty( rc?.token ) ) {
return event.setView( "resetpassword/malformedurl" );
}
var rows = getInstance( "User" ).firstWhere( "id", rc.user );
if( isNull( rows ) ) {
return event.setView( "resetpassword/malformedurl" );
}
if( compare(rows.getToken(), rc.token) != 0 ) {
return event.setView( "resetpassword/expiredtoken" );
}
if ( rows.getExpiration() > now() ) {
return event.setView( "resetpassword/index" );
}
return event.setView( "resetpassword/expiredtoken" );
}
describe("Tests for default route", () => {
describe("bad request cases", () => {
describe("malformedurl cases" , () => {}
describe("Tests for user and token", () => {})
it("it responds with malformedurl if the user is missing", () => {
})
it("it responds with malformedurl if the user is empty", () => {
})
it("it responds with malformedurl if the token is missing", () => {
})
it("it responds with malformedurl if the token is empty", () => {
})
})
it("it responds with malformedurl if the user is not found", () => {
})
})
describe("Expired token cases", () => {
it("it responds with expiredtoken if the rows token is not the same as the request token", () => {
})
it("it responds with expiredtoken if the rows token after now", () => {
})
})
})
it("it responds with restpassword when the token and user are valid", () => {
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment