mirror of
https://github.com/r-ca/kidshift-skills.git
synced 2024-10-25 17:14:03 +00:00
暫定実装
This commit is contained in:
parent
d3b5457c0a
commit
d9db668f16
16
src/index.ts
16
src/index.ts
|
@ -3,6 +3,7 @@ import * as AWS from 'aws-sdk';
|
|||
import * as DynamoDBPersistantAttributesAdapter from 'ask-sdk-dynamodb-persistence-adapter';
|
||||
import { DialogState } from 'ask-sdk-model';
|
||||
import MetaService from './service/MetaService';
|
||||
import AuthService from './service/AuthService';
|
||||
|
||||
const LaunchRequestHandler = {
|
||||
canHandle(handlerInput: Alexa.HandlerInput) {
|
||||
|
@ -39,11 +40,18 @@ const KidShiftAuthIntentHandler = {
|
|||
async handle(handlerInput: Alexa.HandlerInput) {
|
||||
const loginCode = Alexa.getSlotValue(handlerInput.requestEnvelope, 'loginCode');
|
||||
|
||||
const message = 'Slot value is ' + loginCode;
|
||||
|
||||
return handlerInput.responseBuilder
|
||||
.speak(message)
|
||||
const tokenResponse = await AuthService.login(loginCode);
|
||||
if (tokenResponse) {
|
||||
handlerInput.attributesManager.setPersistentAttributes(tokenResponse);
|
||||
await handlerInput.attributesManager.savePersistentAttributes();
|
||||
return handlerInput.responseBuilder
|
||||
.speak('Login successful')
|
||||
.getResponse();
|
||||
} else {
|
||||
return handlerInput.responseBuilder
|
||||
.speak('Login failed')
|
||||
.getResponse();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user