Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@matfire/the_movie_wrapper",
"version": "0.6.2",
"version": "0.7.0",
"description": "",
"repository": {
"url": "https://github.com/matfire/TheMovieWrapper",
Expand Down
10 changes: 10 additions & 0 deletions src/services/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ class AuthenticationService {
});
return res.data as SessionResult;
}

async createSessionWithLogin(username:string, password: string): Promise<NewTokenResult> {
const { request_token: requestToken } = await this.getAuthenticationToken();
const res = await this.$http.post('/authentication/token/validate_with_login', {
request_token: requestToken,
username,
password,
});
return res.data as NewTokenResult;
}
}

export default AuthenticationService;
4 changes: 1 addition & 3 deletions src/types/genericService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ class GenericService {
this.$http = client;
}

setSessionId(sId: number) {
this.session_id = sId;
}
setSessionId(sId: number) { this.session_id = sId; }

setLanguage(l:Language) { this.language = l; }
}
Expand Down
7 changes: 6 additions & 1 deletion tests/authentication.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-undef */
import API from '../src/index';

import {describe, beforeAll, test, expect} from "vitest"
import {describe, beforeAll, test, expect, assert} from "vitest"
let client: API;

describe('Authentication Service', () => {
Expand All @@ -14,4 +14,9 @@ describe('Authentication Service', () => {

expect(url).toContain('?redirect_to=http://testUrl.com');
});

test("get token from username + password", async() => {
const data = await client.auth.createSessionWithLogin(process.env.TMDB_USERNAME!, process.env.TMDB_PASSWORD!);
expect(data).toBeDefined();
})
});