我遇到的问题是,在Firebase中成功验证用户身份(浏览器的调试控制台中没有错误)之后,JS文件无法将重定向到第二页。我正在遵循firebase提供的代码,并且也在github中进行了搜索。在这一点上,我不确定我缺少什么。预先感谢您的帮助。
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "LineParser.h"
#include <limits.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#define SYS_OPEN 5
#define SYS_CLOSE 6
#define SYS_READ 3
#define SYS_WRITE 4
#define SYS_lseek 19
#define STDOUT 1
#define STDIN 0
#define STDERR 2
char buf[2048];
typedef struct pair {
char *name;
char *value;
} pair;
typedef struct pList {
pair *curPair;
struct pList *next;
} pList;
pList *head;
void addLink(pList *link);
void addLink(pList *link) {
if (head == NULL) { //head empty
head = link;
} else {
pList *curLink = head;
while (curLink->next != NULL) {
curLink = curLink->next;
}
curLink->next = link;
}
}
void print() {
printf("%s", head->curPair->name);
}
void dummyFunc() {
pair *p = (pair *)malloc(sizeof(pair));
p->name = "User1";
p->value = "123";
pList *link = (pList *)malloc(sizeof(pList));
link->curPair = p;
link->next = NULL;
addLink(link);
head = (pList *)malloc(sizeof(pList));
head->curPair = p;
head->next = NULL;
print();
}
int main(int argc, char *argv[]) {
char argVals[3];
argVals[2] = '\0';
//init the list
head = NULL;
while (1 == 1) {
fgets(buf, 2048, stdin);
if (strcmp(buf, "dummy") == 0) {
dummyFunc();
}
}
}
答案 0 :(得分:0)
替换
function initApp() {
firebase.auth().onAuthStateChanged(function(user) {
if(user) {
// User is signed in
window.location = 'secondpage.html';
} else {
alert('test!.');
}
}
)}
使用
firebase.auth().onAuthStateChanged(function(user) { if(user) { window.location.href = 'secondpage.html'; } else { alert('test!.'); } } )
您需要将代码块移到函数(initApp()
)之外